473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C# E-mail Client Mails Not Received

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:

Expand|Select|Wrap|Line Numbers
  1.         public string SendEmail()
  2.         {
  3.             try
  4.             {
  5.                 using (System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(EmailFrom, EmailTo))
  6.                 {
  7.                     message.Subject = ConfigurationManager.AppSettings["emailSubject"].ToString();
  8.                     message.Body = ConfigurationManager.AppSettings["emailMainBody"].ToString() + "\n\nSent On:\n" + DateTime.Now.ToString() + "\n" + SerialPortCommands.RemoveControlCharacterPairs(SerialPortCommands.Asciireport);
  9.                     //System.Net.Mail.SmtpClient Client = new System.Net.Mail.SmtpClient("localhost");
  10.                     System.Net.Mail.SmtpClient Client = new System.Net.Mail.SmtpClient("127.0.0.1");
  11.                     Client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis;
  12.                     Client.Send(message);
  13.                     Thread.Sleep(2000);
  14.                 }
  15.                 return null;
  16.             }
  17.             catch (Exception ex)
  18.             {
  19.                 Log.WriteToLog(ex);
  20.                 return "Error Code: email-1";
  21.                 Application.Restart();
  22.             }
  23.         }
And here are the relevant portions from my App.Config file:

Expand|Select|Wrap|Line Numbers
  1. <add key="ToAddress" value="AddressSendingTo@gmail.com"/>
  2.     <add key="FromAddress" value="test@foo.com"/>
  3.     <add key="emailSubject" value="==DEX Collector Message== Your Dex Report Has Been Sent"/>
  4.     <add key="emailMainBody" value="Vending Machine DEX Data"/>
  5.     <add key="MessageSendTime" value="1:17:00 PM"/>
any help would be greatly appreciated, as I am quite stumped :)
Aug 11 '08 #1
27 8688
Curtis Rutland
3,256 Expert 2GB
Are you sure that your emails aren't going to your junk mail boxes? I almost drove myself crazy that way once
Aug 12 '08 #2
Are you sure that your emails aren't going to your junk mail boxes? I almost drove myself crazy that way once
When I check my company e-mail address, I find no e-mail in the junk mail box. When I send to my gmail account, the e-mail always goes through with no problem.
Aug 12 '08 #3
Plater
7,872 Expert 4TB
I would check the logs on the company email server, they may be getting rejected before even making it to client's emails.
Are you sending the emails from a valid email account? Have you checked THAT accounts email box? There might be like "destination unreachable" or something emails in there that might better describe it.
Aug 12 '08 #4
I would check the logs on the company email server, they may be getting rejected before even making it to client's emails.
Are you sending the emails from a valid email account? Have you checked THAT accounts email box? There might be like "destination unreachable" or something emails in there that might better describe it.
Well, I'm not actually sending from an e-mail account that I have set up. For example I can use a purely non-existent dummy address "test@foo.com", to get the reports sent to gmail.
Aug 12 '08 #5
Plater
7,872 Expert 4TB
Well, I'm not actually sending from an e-mail account that I have set up. For example I can use a purely non-existent dummy address "test@foo.com", to get the reports sent to gmail.
Hmm, try sending from a valid email account and see if your company's server lets the emails go through?
Aug 12 '08 #6
Hmm, try sending from a valid email account and see if your company's server lets the emails go through?
I have tried that from my development pc here at work, which does have an e-mail account set up with the company and it works ;however, this won't be doable for the pc's that are going to be hosting the application out in the field. I did consult IT, and found out that our e-mail accounts are actually handled by godaddy.com, would this have any impact on changes that I might have to make to my code?
Aug 12 '08 #7
Curtis Rutland
3,256 Expert 2GB
I think that it just has to come from a real valid email address. It can be the same one, but they have to be real.

That's one of those things that are determined by the server.
Aug 12 '08 #8
Plater
7,872 Expert 4TB
Yes, just make a dummy account on the email server for it. We use one that's ReportServer@ourdomain.com that sounds out reports
Aug 12 '08 #9
Yes, just make a dummy account on the email server for it. We use one that's ReportServer@ourdomain.com that sounds out reports
Do you used SmtpClient.Credentials = new NetworkCredential("username","password"); anywhere in your code, with the object reference to the SmtpClient used instead of directly here of course :)
Aug 12 '08 #10
Plater
7,872 Expert 4TB
Well technically no, because I built my own SMTPClient as I disliked the built in one.
But yes, I *DO* send the authentication information to the mail server, my mail server won't send emails out unless you are a valid user.
Aug 12 '08 #11
Well technically no, because I built my own SMTPClient as I disliked the built in one.
But yes, I *DO* send the authentication information to the mail server, my mail server won't send emails out unless you are a valid user.
Have you had success sending to e-mail accounts hosted on goDaddy servers?
Aug 12 '08 #12
Plater
7,872 Expert 4TB
Have you had success sending to e-mail accounts hosted on goDaddy servers?
I have not had any failures that I have seen.
Aug 12 '08 #13
I have not had any failures that I have seen.
I just can't figure out what it could be. I am able to send to gmail just fine without using credentials.
Aug 12 '08 #14
Plater
7,872 Expert 4TB
I just can't figure out what it could be. I am able to send to gmail just fine without using credentials.
And I we all keep telling you that you need to use credentials.
There really shouldn't be anything difficult to grasp on this concept.
Have you even tried to use valid credentials?
Aug 12 '08 #15
And I we all keep telling you that you need to use credentials.
There really shouldn't be anything difficult to grasp on this concept.
Have you even tried to use valid credentials?
I tried using credentials from my gmail account yes "username" and "password", and when that didn't work, I tried "username@gmail.com", and "password".
Aug 12 '08 #16
Plater
7,872 Expert 4TB
Ok now I don't know what you were doing.
You would not be able to send ANY email through gmail's mail servers without authenticating and using SSL, so you are probably using your company's mail server to send the mail. You must provide a valid login for THAT server in order to send emails successfully.
Aug 12 '08 #17
Ok now I don't know what you were doing.
You would not be able to send ANY email through gmail's mail servers without authenticating and using SSL, so you are probably using your company's mail server to send the mail. You must provide a valid login for THAT server in order to send emails successfully.
Well, I'm actually sending from the pc that I am running the application from. I set the SmtpClient as the local host (127.0.0.1). The pc is on a network independent from the one at work (a Verizon cellular modem). I do honestly have a misunderstanding of how to use credentials. With my new description, do you believe still that I need the credentials for the server at my company which I would be sending to and not from?
Aug 12 '08 #18
Well, I'm actually sending from the pc that I am running the application from. I set the SmtpClient as the local host (127.0.0.1). The pc is on a network independent from the one at work (a Verizon cellular modem). I do honestly have a misunderstanding of how to use credentials. With my new description, do you believe still that I need the credentials for the server at my company which I would be sending to and not from?
It occurs to me that if I had my SmtpClient as the localhost, I would have to alter some settings for my IIS virtual SMTP server, so that it was configured for authentication rather than anonymous access, and then in my code, add the credentials to my localhost's IIS virtual SMTP server. Plater, is this what you were trying to tell me to have authenticated? If so, I apologize for being too dense :)
Aug 12 '08 #19
Plater
7,872 Expert 4TB
Hmmm no. It had actually not occured to me that you could be using localhost to send the emails. Will the final product be run in the same manor?

The crenedtials supplied are for the server you are sending mail from. so if you are sending mail from a localhost, I now understand your confusion about what credentials to send.
That being said there are a number of other things in the SMTP protocol that could cause your emails to be rejected. It's possible that godaddy implents the part of the protocol that says there needs to be a valid MX record for the address that is SENDING the messages.
i.e. it needs to be able to go -> somename@somedomain.com....checking the lookup for somedomain.com
They may also go the next step which would be reverse validation and attempt to verify that someuser is a valid username in somedomain.com

and it could also be none of those and something else entirely.
Your best bet might be to get in touch with whoever handles your email and see if they can find anything in the logs about why your messages are rejected
Aug 12 '08 #20
Hmmm no. It had actually not occured to me that you could be using localhost to send the emails. Will the final product be run in the same manor?

The crenedtials supplied are for the server you are sending mail from. so if you are sending mail from a localhost, I now understand your confusion about what credentials to send.
That being said there are a number of other things in the SMTP protocol that could cause your emails to be rejected. It's possible that godaddy implents the part of the protocol that says there needs to be a valid MX record for the address that is SENDING the messages.
i.e. it needs to be able to go -> somename@somedomain.com....checking the lookup for somedomain.com
They may also go the next step which would be reverse validation and attempt to verify that someuser is a valid username in somedomain.com

and it could also be none of those and something else entirely.
Your best bet might be to get in touch with whoever handles your email and see if they can find anything in the logs about why your messages are rejected
client.UseDefaultCredentials = true;
would send my local host's Credentials correct?
Aug 12 '08 #21
Plater
7,872 Expert 4TB
client.UseDefaultCredentials = true;
would send my local host's Credentials correct?
Mmm I think it actually looks in either machine.config or web.config (depending on application type) for them. Unsure what it will send if cannot find them.
Aug 12 '08 #22
Mmm I think it actually looks in either machine.config or web.config (depending on application type) for them. Unsure what it will send if cannot find them.
I have another question related to this ;however, at this point should I just go ahead and start a new thread?
Aug 12 '08 #23
Curtis Rutland
3,256 Expert 2GB
If it isn't directly related, yes.

Go ahead and post it. We can merge/split it if we need to.
Aug 12 '08 #24
joedeene
583 512MB
Well technically no, because I built my own SMTPClient as I disliked the built in one.
But yes, I *DO* send the authentication information to the mail server, my mail server won't send emails out unless you are a valid user.

hey plater, you said you built your own smtpclient class, that has to be awesome, how would you come across doing that? did you implement any of it with the webclient class? just curious
Aug 13 '08 #25
Plater
7,872 Expert 4TB
I did it with Sockets and the RFCs for the SMTP specs
Aug 13 '08 #26
joedeene
583 512MB
I did it with Sockets and the RFCs for the SMTP specs
what are 'RFCs'? i typed it in google with .net nothing relevant came up
Aug 13 '08 #27
Plater
7,872 Expert 4TB
RFCs are Request For Comments. They are used to define internet standards. They are not related to .NET
Aug 13 '08 #28

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Shagshag | last post by:
hello, does anyone know of a full python + wxWindows email client ? google didn't help me... thanks,
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
3
by: | last post by:
Hi grp, I new to this grp and python too. i have started writing few python scripts myself. now i am planning to write a bear minimum email client in pyhton. i found the smtp module of python...
7
by: Daven Thrice | last post by:
I know how to send email out of Access, and that's no problem. What I need to figure out is how to receive email into access. Say that I give access an email address, such as access@daven.com. I...
2
by: Marcus | last post by:
Is there a way to have Access 2002 open a particular email client, when using DoCmd.SendObject? So far, Access simply opens the default email client that is set under Control Panel/Internet...
1
by: Craig | last post by:
Hiya Everyone, I've just started the development of an email client using the .NET classes and C# ( I figured its a good way to get my hands dirty with ..NET). Anyhow, here's the situation... ...
1
by: Larry Rebich | last post by:
I'm trying to launch the user's email client using 'MailTo:'. So I put a button on an aspx page and wrote some .vb code to use 'Mailto:' and it works on my development machine when I press the...
5
by: Franz Steinhaeusler | last post by:
Hi, although I have googled, I didn't find a Python email client program fitting to my needs. What I want is a program (it doesn't have to be so sophisticated as thunderbird) written totally in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.