Archive for the ‘GoDaddy’ Category

How to send mail using Gmail in ASP.Net with Godaddy Server?

May 31, 2011 12 comments

Cannot send email in ASP.Net through GoDaddy Servers?

In ASP.Net we can sennd mail to anyone using gmail smtp server. We have created codes for sending mail using gmail credentials and it is working fine in local. But when we uploaded to the server we are unable to send mail using the options. The thing is that we are using GoDaddy Server as hosting server and it is not supported the gmail smtp server to send mail.

How to Send mail in ASP.Net with GoDaddy Server

Inorder to send mail using ASP.Net we got a support from godaddy department and now it is working fine. Following are the codes for sending mail in ASP.Net with GoDaddy Server:

using System.Web.Mail;

public static void sendEmail(EmailDetails objEmail)
                string SERVER = ConfigurationSettings.AppSettings["MailServer"].ToString();

                MailMessage oMail = new System.Web.Mail.MailMessage();
                oMail.From = objEmail.From;
                oMail.To = objEmail.To;
                oMail.Cc = ConfigurationSettings.AppSettings["AdminEmailID"].ToString();
                oMail.Subject = objEmail.Subject;
                oMail.BodyFormat = MailFormat.Html;   // enumeration
                oMail.Priority = MailPriority.High;   // enumeration
                oMail.Body = objEmail.Message;
                SmtpMail.SmtpServer = SERVER;
                oMail = null; // free up resources
            catch (Exception ex)

Here we have a object ‘objEmail’ which holds the mail details such as from address, to address, subject etc. We have to use System.Web.Mail class for send mail. Here we are taking server details from web.config as given below.

  <add key="MailServer" value="" />


When we are running in local system the above code is working fine, but when we uploaded to goDaddy server send mail is not working. Then we have to change mail server details in web.config to following one.

<add key="MailServer" value="" />
Categories: DotNet, GoDaddy Tags: ,
<span>%d</span> bloggers like this: