SendMailToQueue Method


Send email to EASendMail Service (Email Queuing).

[Syntax]
Visual C++: HRESULT SendMailToQueue(long* pVal)
Visual Basic: SendMailToQueue() As Long

Return Value

Return zero if successful, or return non-zero if failed.

Remarks

EASendMail Service is a light and fast email delivery service which works with EASendMail SMTP .Net Component / ANSMTP SMTP Component to enable your application to send mass emails in background service. Along with its ability to picking recipients from database in background and sending email in specified datetime, it eases your task in developing featured email application such as newsletter application. We strongly recommend you to use EASendMail Service with your ASP/Web Application. To learn more detail about SendMailToQueue method, please refer to Work with EASendMail Service (Email Queuing) section.
If your application is running on the same server of EASendMail Service, then please use SendMailToQueue or SendMailToQueueEx method; If your appliation want to send email to EASendMail Service on remote server, you should use PostToRemoteQueue method.

Example

[ASP/VBScript] The following example demonstrates how to send email with EASendMail SMTP Component. To get the full samples of EASendMail, please refer to Samples section.

[ASP, VBScript - Send Email to Queue]

Const ConnectNormal = 0
Const ConnectSSLAuto = 1
Const ConnectSTARTTLS = 2
Const ConnectDirectSSL = 3
Const ConnectTryTLS = 4

Sub SendMail()
    Dim oSmtp
    Set oSmtp = Server.CreateObject("EASendMailObj.Mail")

    ' For evaluation usage, please use "TryIt" as the license code.
    oSmtp.LicenseCode = "TryIt"
 
    '  Your SMTP server address, if you don't set server, EASendMail service uses the server setting in EASendMail Service Manager.
    oSmtp.ServerAddr = "smtp.emailarchitect.net" 

    '  User and password for ESMTP authentication
    oSmtp.UserName = "test@emailarchitect.net" 
    oSmtp.Password = "testpassword" 

    '  If server supports SSL/TLS connection, SSL/TLS is used automatically.
    oSmtp.ConnectType = ConnectTryTLS

    oSmtp.Charset = "utf-8" 
    
    oSmtp.From      = "Tester"
    oSmtp.FromAddr  = "tester@adminsystem.com"
    
    Dim recipients
    ' separate multiple addresses with comman(,)
    recipients = "NickName <to@adminsystem.com>, to1@adminsystem.com, to2@adminsystem.com"
    
    ' if you want to EASendMail service send the email after 10 minutes, please use the following code.
    ' you can also cancel the scheduled task in EASendMail Service Manager->Queue Monitor->Scheduled Tasks 
    ' oSmtp.Date = DateAdd("n", 10, Now())
        
    oSmtp.AddRecipientEx recipients, 0  ' Normal recipient 
    ' oSmtp.AddRecipient CCName, CCEmailAddress, 1 'CC  
    ' oSmtp.AddRecipient BCCName, BCCEmailAddress, 2 'BCC  
    ' To avoid too many email address in the To header, 
    ' using the following code can only 'display the current recipient
    oSmtp.DisplayTo = "{$var_rcpt}"

    ' attaches file to this email 
    ' oSmtp.AddAttachment "c:\test.txt"
    
    Dim subject, bodytext
    subject = "test subject"
    bodytext = "Dear {$var_rcptname}, your email address is {$var_rcptaddr}"
    
    oSmtp.Subject   = subject
    oSmtp.BodyText  = bodytext 
    
    Dim hres
    hres = oSmtp.SendMailToQueue()

    If hres = 0 Then
        Response.Write "Message was sent to EASendMail service successfully!" 
    Else 
        Response.Write "Error code: " & hres & "Please make sure you installed EASendMail Service on the server!" 'Get last error description 
    End If

End Sub

See Also

Work with EASendMail Service (Email Queuing)
SendMailToQueueEx Method
PostToRemoteQueue Method

Online Tutorials

Send Email in MS SQL Server - Tutorial
Send Email with Queue in ASP.NET + C#
Send Bulk Emails with Database Queue in ASP.NET + C#
Send Email with Queue in ASP.NET + VB
Send Bulk Emails with Database Queue in ASP.NET + VB
Send Email with Queue in ASP + VBScript
Send Bulk Emails with Database Queue in ASP + VBScript

Online Examples

VB6 - Email Queue with EASendMail Service
VB6 - Email Queue with Database
VC++ - Email Queue with EASendMail Service
VC++ - Email Queue with Database
Delphi - Email Queue with EASendMail Service
Delphi - Email Queue with Database