I am looking for Sample code For Auto Schedule Mass emails Daily on a Specified Time
Thanks
corpimg
I am looking for Sample code For Auto Schedule Mass emails Daily on a Specified Time
Thanks
corpimg
Hi corpimg,
Hi,
I have tried to Auto-schedule Mass emails using another option of the API, but I am afraid to inform that this is not supported by the API, and you will have to achieve this by manually setting the time in your application. Once your application detects that its time to send emails, you can use the Bulk Message sending facility to send Mass emails within short time using your favourite SMTP client. Please refer to the following code for your reference to send bulk emails using Aspose.Email API.
//Create SmtpClient as client and specify server, port, user name and password
SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "username", "password");
client.EnableSsl = true;
client.SecurityMode = SmtpSslSecurityMode.Explicit;
//Create instances of MailMessage class
//Specify To, From, Subject and Message
MailMessage msg1 = new MailMessage("from@gmail.com", "to1@xyz.com", "Subject1", "message1 Body");
MailMessage msg2 = new MailMessage("from@gmail.com", "to2@xyz.com", "Subject2", "message2,Body");
MailMessage msg3 = new MailMessage("from@gmail.com", "to3@xyz.com", "Subject3", "message3,Body");
//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("Message sent");
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.ToString());
}