Note that there are some explanatory texts on larger screens.

plurals
  1. POSMTP email "Service" I can include in my C# project?
    primarykey
    data
    text
    <p>I've written several programs that send email from C#. This works great in winXP, but I find it breaks in Win7. My understanding is that even though the SMTP server I'm referencing is on another computer, the sending computer needs to have the SMTP service installed (and win7 does not). </p> <p>I know its possible to install a third party SMTP server, but then I'd need to do that on every computer running my programs. Instead, I'd like to include a temporary SMTP server in my project that I can use entirely from code to do the same job. Does anyone know of a library (or sample code) on how I can include a temporary SMTP server in my project?</p> <p>Here is my code:</p> <pre><code>public static void sendEmail(String[] recipients, String sender, String subject, String body, String[] attachments) { MailMessage message; try { message = new MailMessage(sender, recipients[0]); } catch (Exception) { return; } foreach (String s in recipients) { if (!message.To.Contains(new MailAddress(s))) message.To.Add(s); } message.From = new MailAddress(sender); message.Subject = subject; message.Body = body; message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient("PRIVATE.PRIVATE.PRIVATE", 25); smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; //smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = true; if (attachments.Length &gt; 0) { foreach (String a in attachments) { message.Attachments.Add(new Attachment(a)); } } try { smtp.SendAsync(message, null); </code></pre>
    singulars
    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.
    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