SendMail Method

Sends a new email.

Syntax

int SendMail(bool bsaveToSentItems);

Remarks

This method sends a new message. Use the Message* (excluding MessageInfo* properties and Message) to set the fields of the message that will be sent. To add an attachment, use the MessageAttachments* properties to add the attachment information. As a note, the relevant properties are not cleared after the method is called. It is recommend to do so after calling this method.

Example: Simple Email


office365.MessageSubject = "I saw a Tree";
office365.MessageImportance = "High";
office365.MessageBodyContentType = "TEXT";
office365.MessageBodyContent = "It was in my back yard initially. It was still there when I last checked.";
office365.MessageTo = "TreeLookOut@gmail.com";

office365.SendMail(True);
Example: HTML email with Attachments
office365.SetMessageSubject("Subject");
office365.SetMessageBodyContentType("HTML");
office365.SetMessageBodyContent("<p>Body</p><img src='cid:test1'>");
office365.SetMessageTo("email@example.com");
	
//Set up attachments
//Inline:
office365.SetMessageAttachmentCount(2);
office365.SetMessageAttachmentFile(0, "./test.png");
office365.SetMessageAttachmentName(0, "test picture");
office365.SetMessageAttachmentContentId(0, "test1");
office365.SetMessageAttachmentIsInline(0, true);

//Normal
office365.SetMessageAttachmentFile(1, "./test.txt");
office365.SetMessageAttachmentName(1, "test file");

office365.SendMail(true);

Error Handling

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