AddAttachment Method

Adds an attachment to an existing message.

Syntax

ANSI (Cross Platform)
int AddAttachment(const char* lpszMessageId, const char* lpszName, const char* lpszLocalFile);

Unicode (Windows)
INT AddAttachment(LPCWSTR lpszMessageId, LPCWSTR lpszName, LPCWSTR lpszLocalFile);
- (void)addAttachment:(NSString*)messageId :(NSString*)name :(NSString*)localFile;
#define MID_OFFICE365_ADDATTACHMENT 2

CLOUDMAIL_EXTERNAL int CLOUDMAIL_CALL CloudMail_Office365_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

This method adds an attachment to an existing message, specified by the MessageId parameter. To add a more complex attachment, set the Name and LocalFile parameters and the class will use the first attachment in the MessageAttachments* properties. As a note, this will not clear the MessageAttachments* properties. If the file is larger than the value set in the AttachmentSimpleUploadLimit configuration, then the class will use an upload session to upload the attachment in fragments. The size of the fragments are specified in the AttachmentFragmentSize configuration.

This method is not used to add attachments to messages that are sent with the SendMail method.

Example (Adding a Simple Attachment to a New Draft)


office365.CreateDraft(0, "");
String messageId = office365.MessageInfo[0].Id;

office365.AddAttachment(messageId, "file1.zip", "C:\file1.zip");
Example (Adding a Simple Attachment to a New Draft)


office365.MessageSubject = "Subject";
office365.MessageBodyContentType = "html";
office365.MessageBodyContent = "<p>Body</p><img src='cid:test1'>";
office365.MessageTo = "email@example.com";
office365.CreateDraft(0, "");
String messageId = office365.MessageInfo[0].Id;

office365.AddAttachment(messageId, "file1.zip", "C:\file1.zip");
Example (Adding a Complex Attachment to a New Draft)
office365.SetMessageSubject("Subject");
office365.SetMessageBodyContentType("HTML");
office365.SetMessageBodyContent("<p>Body</p><img src='cid:test1'>");
office365.SetMessageTo("email@example.com");

office365.CreateDraft(0,"");

office365.SetMessageAttachmentCount(1);
office365.SetMessageAttachmentFile(0, "./test.png");
office365.SetMessageAttachmentContentId(0, "test1");
office365.SetMessageAttachmentIsInline(0, true);

office365.AddAttachment(office365.GetMessageInfoId(0), "", "");

office365.SendDraft(office365.GetMessageInfoId(0));

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
Cloud Mail 2020 C++ Edition - Version 20.0 [Build 8308]