Cloud Mail 2020 Node.js Edition

Questions / Feedback?

AddAttachment Method

Adds an attachment to an existing message.

Syntax

office365.addAttachment(messageId, name, localFile, [callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

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));

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