SMTP feedback from project
-
I am working on a feedback form that basically emails the server a small message. The main information that I need in the (outgoing) SMTP server for the user's account. One problem is how to find the default SMTP server on the user's machine. Considering the following code...,
private bool GetSmtpAccountInfo() { RegistryKey key = Registry.CurrentUser.OpenSubKey( @"Software\Microsoft\Internet Account Manager\Accounts\00000001" ); if (key != null) { DisplayName = key.GetValue("SMTP Display Name").ToString(); DefaultEmailAddress = key.GetValue("SMTP Email Address").ToString(); SMTPServer = key.GetValue("SMTP Server").ToString(); key.Close(); return true; } return false; }
which gets the information from the registry key from the default Internet Account. This still seems to be destined for failure. Is there a better way? Any help would be greatly appreciated! Mark
-
I am working on a feedback form that basically emails the server a small message. The main information that I need in the (outgoing) SMTP server for the user's account. One problem is how to find the default SMTP server on the user's machine. Considering the following code...,
private bool GetSmtpAccountInfo() { RegistryKey key = Registry.CurrentUser.OpenSubKey( @"Software\Microsoft\Internet Account Manager\Accounts\00000001" ); if (key != null) { DisplayName = key.GetValue("SMTP Display Name").ToString(); DefaultEmailAddress = key.GetValue("SMTP Email Address").ToString(); SMTPServer = key.GetValue("SMTP Server").ToString(); key.Close(); return true; } return false; }
which gets the information from the registry key from the default Internet Account. This still seems to be destined for failure. Is there a better way? Any help would be greatly appreciated! Mark
Let me first give you a tip, about never to write such sensitive code that is not portable on all systems, a better solution is to use specialized packages and technologies for that, now regarding your question I would 100% go to Perl or Python .Net embedded scripts... I hope this tip will help you..
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
-
Let me first give you a tip, about never to write such sensitive code that is not portable on all systems, a better solution is to use specialized packages and technologies for that, now regarding your question I would 100% go to Perl or Python .Net embedded scripts... I hope this tip will help you..
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
-
Mohamad K Ayash wrote:
Perl or Python .Net embedded scripts...
Can you elaborate on this? Mark
Ok this may be a bit complicated, are you planning to create a web application that sends messages to the users SMTP server, if this was the case you may use PHP or ASP.NET built in capabilities to do so and that is generally easy, or if you need it in C# you may access the SMTP port 25 which works similir to ping and hence get a request with the client's SMTP server, without the need to access the registry!! I hope this helps. Best Wishes Mark!:)
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
-
I am working on a feedback form that basically emails the server a small message. The main information that I need in the (outgoing) SMTP server for the user's account. One problem is how to find the default SMTP server on the user's machine. Considering the following code...,
private bool GetSmtpAccountInfo() { RegistryKey key = Registry.CurrentUser.OpenSubKey( @"Software\Microsoft\Internet Account Manager\Accounts\00000001" ); if (key != null) { DisplayName = key.GetValue("SMTP Display Name").ToString(); DefaultEmailAddress = key.GetValue("SMTP Email Address").ToString(); SMTPServer = key.GetValue("SMTP Server").ToString(); key.Close(); return true; } return false; }
which gets the information from the registry key from the default Internet Account. This still seems to be destined for failure. Is there a better way? Any help would be greatly appreciated! Mark
-
Ed.Poore wrote:
and because of company policy I couldn't access their SMTP server
So you are saying that you are unable to send email through the company server? If you are sending mail, the SMTP server is the outgoing. So you have to be able to access that server (setting for the user's machine). That is the problem. The target server (for the recipient) is not.
SmtpClient client = new SmtpClient(); client.Host = someServerName; // e.g. smtp-server.domain.com client.Port = 25;
Mark