Sending queued emails

ActiveQ

Sending queued emails

 

Send a queued email is very simple. You only need to save or copy a valid RFC822 representation of an email to the pickup directory. Not all email applications and components allow you to save messages in an RFC822 format. The sample below demonstrates how to do that using ActiveMail, our best selling email component.

 

Using C#

 

Message message = new Message();

message.From = new Address("[email protected]","John Doe");

message.To.Add("[email protected]","Mike Johns");

message.Subject = "hey!";

message.Attachments.Add("C:\\myfile.doc");

message.BodyHtml.Text = "As promised, the requested document.<br /><br />Regards,<br />John.";

message.StoreToFile("C:\\messages\\outbox\\tobesent.eml", true);

 

Using VB.NET

 

Dim message As New Message

message.From = new Address("[email protected]","John Doe")

message.To.Add("[email protected]","Mike Johns")

message.Subject = "hey!"

message.Attachments.Add("C:\myfile.doc")

message.BodyHtml.Text = "As promised, the requested document.<br /><br />Regards,<br />John."

message.StoreToFile("C:\messages\outbox\tobesent.eml", true)

 

We pass true to the StoreToFile method to ask ActiveMail to use a temp filename when writing the content of the email then rename it when it’s done. This is required because ActiveQ can process the directory and search for .eml mails. If the mail is not completely written, ActiveQ will send an erroneous email. It’s relatively impossible when sending small emails like this one, but bigger emails can cause the problem. Please note that this feature is not available in all mail components.

 

If you want to schedule your email, see Sending scheduled emails.

 

 

Copyright © 2003 Active Up SPRL - All Rights Reserved - http://www.activeup.com