Send Email
Question:
Question: Hi all,
I am a newbie to sending email. I need some guidance.
I have code written for sending email using System.Net.Mail … SMPT.
Questions:
1. What do i need in order for the web server to run my code… eg .. do i need to have authentication set up …Etc…
Below is code that i am using ….
This works fine when i run it on my desktop but when i run in production off the web server i dont get any error or any emails. (is there something i am missing?)
code snip1:
using System.Net.Mail;
:
:
SmtpClient mailClient = new SmtpClient();
mailClient.Host = “smtp.somelink.com”;
mailClient.UseDefaultCredentials = true;
mailClient.Send(sender);
public class EmailMessage
{
#region Static Definitions
//private static log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
internal static string SMTPServer;
static EmailMessage()
{
SMTPServer = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"] ; //System.Configuration.ConfigurationSettings.AppSettings["SMTPServer"];
if (SMTPServer == null)
{
SMTPServer = “localhost”;
}
}
#endregion
Solution:
I really should finish my replies before clicking Submit! Hopefully this will be the last one unless you have another question lol
SMTPServer = “localhost”;
That should be something like
SMTPServer = “000.000.000.000″ with the 0’s beign the actual address. If the server is your own machine then just do ipconfig in Command Prompt (Start->Run->cmd) and it will tell you your IP.













Comments (0)
Trackbacks - Pingbacks (0)
Leave a Reply