Note that there are some explanatory texts on larger screens.

plurals
  1. POThe right way to send email from Windows service
    primarykey
    data
    text
    <p>I need to send lots of emails(probably hundreds a day) on schedule base. The way I'm thinking to do it is as follows but the problem is that my Body field can get very big, and if i add it as string it gets ugly. </p> <pre><code> SmtpClient client = new SmtpClient(); //host and port picked from web.config client.EnableSsl = true; MailMessage message = new MailMessage(); message.Body = "test from winservice"; // HERE IS MY PROBLEM message.IsBodyHtml = true; message.From = new MailAddress("donotreply@abcde.com"); message.Subject = "My subject"; message.To.Add(new MailAddress("piniusha@abcde.com")); try { client.Send(message); } catch (Exception) { } </code></pre> <p>When i had to do it from aspx page i used</p> <pre><code> MailDefinition message = new MailDefinition(); message.BodyFileName = @"~\EmailTemplate\Template1.htm"; ListDictionary replacements = new ListDictionary(); replacements.Add("&lt;% Name %&gt;", this.txtName.Text); replacements.Add("&lt;% PhoneOrEmail %&gt;", this.txtPhoneOrEmail.Text); replacements.Add("&lt;% Message %&gt;", this.txtMessage.Text); MailMessage msgHtml = message.CreateMailMessage(RECIPIENTS, replacements, new LiteralControl()); </code></pre> <p>I think it is elegant solution but i don't want to reference to System.Web.UI.WebControls.MailDefinition because i'm in winservice.</p> <p>My questions are: </p> <ol> <li>What is the best way to send bulk emails from winservice? </li> <li>Is it posible to send it from gmail account? or they are going to block me after a while?</li> </ol> <p>thanks for any help. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload