Hi, I am trying to write an application that will e-mail sales data reports once per day. I have largely succeeded in creating the application and I am able to e-mail my reports to some e-mail addresses such as gmail ones ;however, when attempting to send e-mails to addresses on my companies internal server the e-mails never arrive. I was wondering if anyone knew what could allow gmail addresses to receive e-mails from my application, but not allow other servers to receive mail from my application, below is the portion of code doing the e-mailing:
And here are the relevant portions from my App.Config file:
any help would be greatly appreciated, as I am quite stumped :)
Code:
public string SendEmail()
{
try
{
using (System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(EmailFrom, EmailTo))
{
message.Subject = ConfigurationManager.AppSettings["emailSubject"].ToString();
message.Body = ConfigurationManager.AppSettings["emailMainBody"].ToString() + "\n\nSent On:\n" + DateTime.Now.ToString() + "\n" + SerialPortCommands.RemoveControlCharacterPairs(SerialPortCommands.Asciireport);
//System.Net.Mail.SmtpClient Client = new System.Net.Mail.SmtpClient("localhost");
System.Net.Mail.SmtpClient Client = new System.Net.Mail.SmtpClient("127.0.0.1");
Client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis;
Client.Send(message);
Thread.Sleep(2000);
}
return null;
}
catch (Exception ex)
{
Log.WriteToLog(ex);
return "Error Code: email-1";
Application.Restart();
}
}
Code:
<add key="ToAddress" value="AddressSendingTo@gmail.com"/>
<add key="FromAddress" value="test@foo.com"/>
<add key="emailSubject" value="==DEX Collector Message== Your Dex Report Has Been Sent"/>
<add key="emailMainBody" value="Vending Machine DEX Data"/>
<add key="MessageSendTime" value="1:17:00 PM"/>
Comment