SimpleSend Method
Previous  Top  Next


SimpleSend method sends simple text or HTML e-mail to one or more recipients synchronously.

Syntax

[Visual Basic]


Function
 SimpleSend(strFrom As String, strTo As String, strSubject As String, strMessage As StringByRef strError As String) As Long

Example:

Dim
 strError As String
Dim
 numResultCode As Long
numResultCode = objSmtpMail.SimpleSend("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "Test message", strError)

[VBScript]


Function
 SimpleSendScriptable(strFrom, strTo, strSubject, strMessage, ByRef strError)

Example:

Dim
 strError
Dim
 numResultCode
numResultCode = objSmtpMail.SimpleSendScriptable("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "Test message", strError)

[C#]


int
 SimpleSend(string strFrom, string strTo, string strSubject, string strMessage, out string strError);

Example:

string
 strError;
int
 numResultCode = objSmtpMail.SimpleSend("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "Test message", out strError);

[C++]


HRESULT SimpleSend(BSTR strFrom, BSTR strTo, BSTR strSubject, BSTR strMessage, BSTR* pstrError, LONG* pnumResultCode);

Example:

BSTR bstr;
int numResultCode = spSmtpMail->SimpleSend("My Name <me@myisp.com>", "Someone <someone@someisp.com>;someoneelse@someotherisp.com", "test", "Test message", &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.

strMessage [in]
Body of the e-mail message.

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

SimpleSend can be used to send text or HTML e-mails. Body of the e-mail message should start with <html> tag for HTML e-mail messages. This method supports Unicode in the subject and body of the message as well as in the sender's and recipients' names. 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.