SendToQueueEx Method


Submits the message to IIS SMTP pickup folder or to MailBee Message Queue (legacy) or MailBee.NET Queue (modern) system for delivery.

In addition to standard "send-to-queue" functionality, it allows sending messages from fake addresses (From header is ignored) to addresses different from those specified in To/CC/BCC headers.

Sending from fake address commonly used in group mailings to make sure bounce mails are all arrive to the same address.

MailBee Message Queue (MMQ) is a message queuing system which intercepts mail transmissions from the SMTP object and sends them in the background. This allows the SMTP object to operate very quickly. MailBee.NET Queue is a modern version, it adds SSL/TLS support, direct send without SMTP relay server, and many other features. MailBee.NET Queue, however, needs .NET Framework. From the point of view of MailBee SMTP component, both versions behave identically.

IIS SMTP server is also capable of bypassing SMTP protocol and picking messages directly from the file system.

Both MMQ and IIS SMTP use the same queue file format and thus it's possible to use this method to submit into any of these queues. However, IIS SMTP pickup service cannot double first dots on a line as required by the SMTP protocol and thus it's the responsibility of the application which produces .EML files.

In short, before submitting to IIS SMTP pickup service, set IsQueueIIS property value to True.

Another reason to use submitting to the pickup folder (especially in the case of IIS SMTP queue) is security. Often, firewalls do not allow applications to send mail via SMTP. In this case, the only way is to submit messages into the pickup folder of IIS SMTP queue.

Unlike Send/SendEx methods, SendToQueueEx method does not require established connection to SMTP server. Actual connection and data transfer is made by MMQ system. However, LicenseKey property must be still specified.


blnResult = ObjectName.SendToQueueEx(DirPath, [FromAddr], [Recips])  
Parameters:  
DirPath As String Path to the directory used by IIS SMTP (usually, C:\Inetpub\mailroot\pickup) or by MMQ as a storage of message files (QueueDirPath parameter in mmq.ini file) or by MailBee.NET Queue (the default is "c:\MailBeeNetQueue Files\Pickup")  
FromAddr As String (optional) If specified, overrides SMTP.Message.FromAddr setting. This may be used if you want to send email from address different from those specified in From header (sending from fake address)  
Recips As String (optional) If specified, overrides SMTP.Message.ToAddr/CCAddr/BCCAddr setting. This may be used if you want to send email to addresses different from those specified in To/CC/BCC headers  
Return value As Boolean True if successful, False otherwise (invalid license key, queue dir doesn't exist, i/o error, etc.)  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.SMTP")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.SMTP")
'In ASP use Response.Write instead of MsgBox
Mailer.LicenseKey = "put your license key here"
Mailer.Message.ToAddr = "bill@yoursite.com"
Mailer.Message.FromAddr = "joe@mysite.com"
Mailer.Message.Subject = "Hello"
Mailer.Message.ImportBodyText "C:\docs\letter.htm", True
Mailer.IsQueueIIS = True
if Not Mailer.SendToQueueEx("C:\Inetpub\mailroot\pickup", "realsender@server.com") Then MsgBox Mailer.ErrDesc

See Also:

"Creating and sending HTML-formatted messages" Tutorial

Connect Method
Send Method
IsQueueIIS Property
LicenseKey Property


Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.