Quantcast
Channel: Aspose.Email Product Family
Viewing all articles
Browse latest Browse all 2

Re: mass mail

0
0
Hi,

Thank you for your inquiry.

Please use the BulkSend method of SmtpClient to send multiple messages at once. The following code sample shows how to achieve this:

Code:


//Create SmtpClient as client and specify server, port, user name and password
SmtpClient client = new SmtpClient("mail.server.com", 25, "Username", "Password");

//Create instances of MailMessage class
//Specify To, From, Subject and Message
MailMessage msg1 = new MailMessage("msg1@from.com", "msg1@to.com", "Subject1", "message1, how are you?");
MailMessage msg2 = new MailMessage("msg1@from.com", "msg2@to.com", "Subject2", "message2, how are you?");
MailMessage msg3 = new MailMessage("msg1@from.com", "msg3@to.com", "Subject3", "message3, how are you?");
//you can create as many instances of MailMessage class as you like.

//Create an instance of MailMessageCollection class
MailMessageCollection manyMsg = new MailMessageCollection();

manyMsg.Add(msg1);
manyMsg.Add(msg2);
manyMsg.Add(msg3);

//Use client.BulkSend function to complete the bulk send task
try
{

      //Send Message using BulkSend method
      client.BulkSend(manyMsg);

      //Display ‘Message Sent’, only if message sent successfully
      Console.WriteLine("Messages sent");

}
catch (Exception ex)
{
      System.Diagnostics.Trace.WriteLine(ex.ToString());
}


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images