Asked By Reena Jain
18-Nov-09 02:08 AM

I was using this mail setting in web.config file
<appSettings>
<add key="MailServer" value="mail.expertx.us"/>
<add key="Mailpassword" value="exp223inf"/>
<add key="MailuserName" value="info@expertx.us"/>
<add key="Mailhost" value="mail.expertx.us"/>
<add key="MailPort" value="25"/>
<add key="ToEmailId" value="rajmera@gmail.com"/>
<add key="FromEmailId" value="rajmera@gmail.com"/>
<add key="Bcc" value="rajmera@gmail.com"/>
</appSettings>
but since client is using godaddy hosting and they giving the below smtp settings for web.config file:
<system.net>
<mailSettings>
<smtp from="username@domain.com">
<network
host="smtpout.secureserver.net"
port="25"
userName="username@domain.com"
password="yourpassword" />
</smtp>
</mailSettings>
</system.net>
also given one note what is for:-Please note that SMTP Authentication sould be basic (anonymous will not work).
Now how should I change the setting in web.config file to add ‘key’ because I’m using following coding in .cs page for sending mails
public bool SendMail(string MailFrom, string MailTo, string Subject, string Message, string AttachedFile, string strCC, string strBcc)
{
try
{
//Get NetworkCredential UserName and Password for sending mail
string userName = ConfigurationManager.AppSettings["MailuserName"].ToString();
string password = ConfigurationManager.AppSettings["Mailpassword"].ToString();
string smtpHost = ConfigurationManager.AppSettings["MailServer"].ToString();
int smtpPort = Convert.ToInt32(ConfigurationManager.AppSettings["MailPort"].ToString());
SmtpClient oSmtpClient = new SmtpClient();
MailMessage oMailMessage = new MailMessage();
MailAddress oMailAddress = new MailAddress(MailTo);
MailAddress fromMailAddress = new MailAddress(MailFrom);
oMailMessage.To.Add(oMailAddress);
oMailMessage.From = fromMailAddress;
if (strBcc != "")
{
MailAddress mBcc = new MailAddress(strBcc);
oMailMessage.Bcc.Add(mBcc);
}
if (strCC != "")
{
MailAddress mCc = new MailAddress(strCC);
oMailMessage.CC.Add(mCc);
}
oMailMessage.Subject = Subject.Replace("\r\n", "");
oMailMessage.IsBodyHtml = true;
oMailMessage.Body = Message;
oSmtpClient.Host = smtpHost;
oSmtpClient.Port = smtpPort;
if (!(string.IsNullOrEmpty(AttachedFile)))
{
Attachment objAttachment = new Attachment(AttachedFile);
oMailMessage.Attachments.Add(objAttachment);
}
System.Net.NetworkCredential oNetworkCredential = new System.Net.NetworkCredential(userName, password);
oSmtpClient.UseDefaultCredentials = false;
oSmtpClient.Credentials = oNetworkCredential;
oSmtpClient.Send(oMailMessage);
return true;
}
catch (Exception ex) { }
{
}
return true;
}
So how should I adjust the new smpt setting with above code
Thanks in advance