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

Joined
Jan 28, 2010
Messages
3
Reaction score
0
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);
                }
}
 
Joined
Feb 1, 2010
Messages
1
Reaction score
0
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="(e-mail address removed)" 'change to correct address
myMail.To="(e-mail address removed)" ' change to correct address
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing

<-- end file
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top