AddAttachment Method

Adds an attachment to an existing message.

Object Oriented Interface

public function doAddAttachment($messageid, $name, $localfile);

Procedural Interface

cloudmail_office365_do_addattachment($res, $messageid, $name, $localfile);

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 PHP Edition - Version 20.0 [Build 8308]