SimpleSendHtml Method

<< Click to Display Table of Contents >>

Navigation:  Reference > SmtpMail >

SimpleSendHtml Method

 

SimpleSendHtml method imports HTML file from disk and sends HTML e-mail with embedded images to one or more recipients synchronously.

 

Syntax

 

[Visual Basic]


Function SimpleSendHtml(strFrom As String, strTo As String, strSubject As String, strHtmlFile As String, ByRef strError As String) As Long

 

Example:

 

Dim strError As String

Dim numResultCode As Long

numResultCode = objSmtpMail.SimpleSendHtml("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "c:\files\email.html", strError)

 

[VBScript]


Function SimpleSendHtmlScriptable(strFrom, strTo, strSubject, strHtmlFile, ByRef strError)

 

Example:

 

Dim strError

Dim numResultCode

numResultCode = objSmtpMail.SimpleSendHtmlScriptable("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "c:\files\email.html", strError)

 

[C#]


int SimpleSendHtml(string strFrom, string strTo, string strSubject, string strHtmlFile, out string strError);

 

Example:

 

string strError;

int numResultCode = objSmtpMail.SimpleSendHtml("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "c:\\files\\email.html", out strError);

 

[C++]


HRESULT SimpleSendHtml(BSTR strFrom, BSTR strTo, BSTR strSubject, BSTR strHtmlFile, BSTR* pstrError, LONG* pnumResultCode);

 

Example:

 

BSTR bstr;

int numResultCode = spSmtpMail->SimpleSendHtml("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "c:\\files\\email.html", &bstr);

_bstr_t strError(bstr, FALSE);

 

 

Parameters

 

strFrom [in]

Sender's e-mail address. You can also specify sender's name followed by the sender's e-mail address in angled brackets.

 

strTo [in]

List of recipients' e-mail addresses separated by semicolon. You can also specify recipient's name followed by the recipient's e-mail address in angled brackets.

 

strSubject [in]

Subject of the e-mail message.

 

strFileName [in]

Filename of the HTML file to be imported.

 

strError [out]

Contains extended error information if the message failed to be sent, empty string otherwise.

 

Return value

 

Returns numeric result:

   0 if the message was sent successfully;

   -1 if connection to the server failed or in case of other Winsock errors;

   >0 SMTP error code as defined in RFC 821 page 34-35.

 

Remarks

 

SimpleSendHtml can be used to send HTML e-mails with embedded images. This method imports specified HTML file, adds all images referenced in the HTML as inline attachments and modifies HTML as needed. Only images located on disk are added as attachments. Images from the web (http:// or https:// links in HTML) are not attached. Please note that the current version of AddEmail does not import images specified in CSS using url values.

 

This method supports Unicode in the subject and body of the message as well as in the sender's and recipients' names. Please make sure HTML file uses UTF-8 encoding if you want to use Unicode. AddEmail will create Unicode e-mail (UTF-8 encoding) if any part of the message contains Unicode characters.

 

This method is synchronous: it returns after the message was sent or after an error occuried. Please use it with care because single-threaded applications are blocked and can't process user input for the duration of the SimpleSend call. Please refer to SendAsync Method if you want to send messages without blocking your application.