Thread: Sending Email - Using System.Net.Mail

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    1

    Unhappy Sending Email - Using System.Net.Mail

    I am new to CP and wondered if anyone can help me with this issue:
    - building windows application
    - using .NET 2005 (Framework 2.0)

    I am trying to send emails using .Net.Mail but the problem I have is that the emails do not actually send until I exit the application!

    I have tried everything I can think of including running this code on its own thread and changing the delivery method but nothing seems to work.

    I cannot believe that such a simple thing as sending an email could possible be so damn difficult and frustrating - thanks to Microfault.

    Code:
                SmtpClient smtp = new SmtpClient("mysmtpserver");
                // smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
                MailMessage mm = new MailMessage();
                mm.IsBodyHtml = true;
                mm.From = new MailAddress("[email protected]");
                mm.ReplyTo = new MailAddress("[email protected]");
                mm.To.Add(new MailAddress("[email protected]"));
                mm.Body = "<HTML><BODY>Message Body</BODY></HTML>";
                mm.Subject = "Message Subject";
                smtp.Send(mm);
                mm.Dispose();
                mm = null;
                smtp = null;
    Thanks in advance to anyone who can shed some light on this for me.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by b4ip View Post
    I cannot believe that such a simple thing as sending an email could possible be so damn difficult and frustrating - thanks to Microfault.
    LOL. Obviously you have not worked with SMTP before.... No, Email should be eaaaaaaaasy.

    Anyway, from the documents I'm reading, what you're doing should be working.

    http://msdn2.microsoft.com/en-us/library/swas0fwc.aspx

    Is the Send() method blocking like it should?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Spam Filters. ISP based email is dying.
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 03-05-2008, 12:05 PM
  2. sending an email through a C program
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 10-06-2005, 06:10 AM
  3. Sending Email via C++?
    By Monte in forum C++ Programming
    Replies: 0
    Last Post: 07-30-2002, 01:14 PM
  4. sending strings from program to email
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 04-09-2002, 06:23 PM
  5. sending email from (C++)exe file through ASP
    By priya in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2002, 10:14 AM