• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

i cannot send email from gmail using hosting godaddy

it's ok run in my computer i send from gmail  but not work when run online
public static bool sendmail1(string sender, string recipient, string subject, string body, string file)
        {
            //Create Mail Message Object with content that you want to send with mail.
            MailMessage myMailMessage = new MailMessage();

            myMailMessage.To.Add(recipient);
            myMailMessage.From = new MailAddress(sender);
            myMailMessage.Subject = subject;
            myMailMessage.Body = body;
            myMailMessage.IsBodyHtml = true;
            Attachment myAttachment = new Attachment(file);
            myMailMessage.Attachments.Add(myAttachment);

            NetworkCredential mailAuthentication = new NetworkCredential("myxmlexport@gmail.com", "xxx");
            SmtpClient mailClient = new SmtpClient("smtp.gmail.com");

            mailClient.UseDefaultCredentials = false;
              //Enable SSL
            mailClient.EnableSsl = true;
            mailClient.Port = 587;
            mailClient.Credentials = mailAuthentication;
            try
            {
                mailClient.Send(myMailMessage);
                return true;
            }
            catch (Exception ex)
            {
                string ex2 = ex.ToString();
                return false;
            }
        }

        private void authentication()
        {
            System.Net.WebProxy pry = new System.Net.WebProxy("10.10.10.8", 8080);
            pry.Credentials = CredentialCache.DefaultCredentials;
            GlobalProxySelection.Select = pry;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {  string href = "http://www.myxmlexport.com/xml/" + drp_filexml.SelectedItem.Text.Trim();
                string link = string.Format("<a href={0} target=_blank>¿¿¿ ¿¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿¿</a>", href) + "<br />" + DateTime.Now.ToString("dd/MM/yyyy") + "<br />" + DateTime.Now.ToString("hh:mm:ss");
              
                string file = Server.MapPath("xml/Xml_student2011.xml");
                sendmail1("myxmlexport@gmail.com", txtemail.Text.Trim(), "¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿¿ ¿¿ ¿¿¿¿¿¿¿ ¿¿¿¿¿¿¿", string.Format("<html><head></head><body><center><img src=http://www.myxmlexport.com/images/logo.jpg><br /><b>¿¿¿¿ ¿¿¿¿¿ ¿¿¿ ¿¿ ¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿¿</b><br />" + link + "</center></body>"), file);
                 lblsend.ForeColor = System.Drawing.Color.Green;
                lblsend.Text = "¿¿ ¿¿¿¿¿ ¿¿¿ ¿¿¿¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿¿¿";

Open in new window

erroremail.JPG
0
myaspnet
Asked:
myaspnet
  • 4
  • 4
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Godaddy is very restrictive about the methods you can use in ASP.NET.  Here is a page about the things that are supported in Windows hosting: http://community.godaddy.com/help/article/1584?locale=en  What you are trying to be will probably not be allowed on their servers.  I think they will block it to prevent spam.  You will probably have to use their email servers to send anything out from their hosting account.
0
 
myaspnetAuthor Commented:
i'm not understand you i have error on email godaddy
erroremail.JPG
0
 
Dave BaldwinFixer of ProblemsCommented:
I understand you perfectly.  You don't yet understand that Godaddy probably isn't going to let you do what you want.  You need to find out what Godaddy allows and stick with that if you want things to work.  I have accounts on Godaddy and I have had to deal with these things.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
havj123Commented:
we cant send mail using gmail in godaddy
0
 
myaspnetAuthor Commented:
ok thank you
but did you know another site support  send email with gmail
0
 
Dave BaldwinFixer of ProblemsCommented:
I don't know if any other site will support your code.  The two things to look for are whether they support all of the functions you're trying to and whether they will let you connect to an outside email server like Gmail.  Those are the two things you need to know when you look for another hosting company.
0
 
myaspnetAuthor Commented:
beacuse when i send from gmail faster than godaddy email
0
 
Dave BaldwinFixer of ProblemsCommented:
I believe you since Godaddy can take up to 4 hours to send out an email.
0
 
myaspnetAuthor Commented:
ok thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now