Send Method

<< Click to Display Table of Contents >>

Navigation:  Reference > SmtpMail >

Send Method

 

Send method sends e-mail message synchronously.

 

Syntax

 

[Visual Basic]


Function Send(objMessage As AddEmailLib.MailMessage, bUseSmtpServer As Boolean, ByRef strError As String) As Long

 

Example:

 

Dim strError As String

Dim numResultCode As Long

numResultCode = objSmtpMail.Send(objMessage, True, strError)

 

[VBScript]


Function SendScriptable(objMessage, bUseSmtpServer, ByRef strError)

 

Example:

 

Dim strError

Dim numResultCode

numResultCode = objSmtpMail.SendScriptable(objMessage, True, strError)

 

[C#]


int Send(AddEmailLib.MailMessageClass objMessage, bool bUseSmtpServer, out string strError);

 

Example:

 

string strError;

int numResultCode = objSmtpMail.Send(objMessage, true, out strError);

 

[C++]


HRESULT Send(IMailMessage* objMessage, VARIANT_BOOL bUseSmtpServer, BSTR* pstrError, LONG* pnumResultCode);

 

Example:

 

BSTR bstr;

int numResultCode = spSmtpMail->Send(objMessage, TRUE, &bstr);

_bstr_t strError(bstr, FALSE);

 

 

Parameters

 

objMessage [in]

Prepared MailMessage object containing the e-mail message to send.

 

bUseSmtpServer [in]

Specifies whether the message should be sent using SMTP server. If the parameter is true (not equal to zero) message will be send using SMTP server specified in SmtpServer property. If the parameter is false (equal to zero) message will be send directly to the recipients' mail server(s). This parameter is valid for AddEmail Enterprise version only. AddEmail Professional always uses specified SMTP server.

 

strError [out]

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

 

Return value

 

Returns numeric result:

   0 if 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

 

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 Send call. Please refer to SendAsync Method if you want to send messages without blocking your application. Please refer to the SenderHostname topic for more information about sending e-mails directly without using SMTP server of your organization or internet provider (Enterprise version only).