C# mail app - mail not sent and ends up in queue folder

Discussion in '.NET' started by JaikeC, Jan 28, 2010.

  1. JaikeC

    JaikeC

    Joined:
    Jan 28, 2010
    Messages:
    3
    I am writing a C# app that uses the SMTP server on my local pc to send email. I can send email normally (throught email client) but mail is not sent using this very simple C# 2.0 code.

    No exception is generated
    Mail ends up in C:\Inetpub\mailroot\Queue as eml file
    Mail not sent - cannot be seen in Outlook after send and recieve clicked to refresh inbox
    All email addresses and passwords correct

    Here is my code...


    Code:
    private void btnSend_Click(object sender, EventArgs e){
         try
           {
                 MailMessage message = new MailMessage(
                                                   "my email address", 
                                                   "my email address",
                                                   "Test Send Subject",
                                                   "Test Send Body");
               
                 SmtpClient client = new SmtpClient("The name of my mail server in IIS");
                 System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
                cred.UserName = "my email address";
                cred.Password = "my email password";
                client.UseDefaultCredentials = true;
                client.Credentials = cred;
                client.Send(message);
           }
           catch (Exception ex)
                   {
                     MessageBox.Show(ex.Message);
                    }
    }
    JaikeC, Jan 28, 2010
    #1
    1. Advertising

  2. JaikeC

    rowdyr86

    Joined:
    Feb 1, 2010
    Messages:
    1
    Because the message is in the queue it should be ready for sending I would think. Have you verified the outbound queue settings for delivery in SMTP on the server? (e.g. - 10, 15 minutes).

    Are you using a smart host in SMTP settings? If so can you send directly to the smart host (telnet to it and send directly for example)?

    If just using SMTP from on same machine as IIS try using the following in a vbscript to send directly via cdosys.dll:

    begin mail.vbs -->

    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending test email with CDOSYS"
    myMail.From="from_name@example.com" 'change to correct address
    myMail.To="to_name@example.com" ' change to correct address
    myMail.TextBody="This is a message."
    myMail.Send
    set myMail=nothing

    <-- end file
    rowdyr86, Feb 1, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Curt_C [MVP]
    Replies:
    5
    Views:
    358
    Karim
    May 19, 2004
  2. Russell Warren

    Is Queue.Queue.queue.clear() thread-safe?

    Russell Warren, Jun 22, 2006, in forum: Python
    Replies:
    4
    Views:
    671
    Russell Warren
    Jun 27, 2006
  3. Gabriel Rossetti
    Replies:
    3
    Views:
    534
    Jerry Hill
    Apr 25, 2008
  4. fcetrini@gmail.com
    Replies:
    4
    Views:
    276
    fcetrini@gmail.com
    Mar 20, 2007
  5. Kris
    Replies:
    0
    Views:
    467
Loading...

Share This Page