We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

i cannot send email from gmail using hosting godaddy

myaspnet
myaspnet asked
on
Medium Priority
363 Views
Last Modified: 2012-08-14
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
Comment
Watch Question

Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.

Author

Commented:
i'm not understand you i have error on email godaddy
erroremail.JPG
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.

Commented:
we cant send mail using gmail in godaddy

Author

Commented:
ok thank you
but did you know another site support  send email with gmail
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.

Author

Commented:
beacuse when i send from gmail faster than godaddy email
Fixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
ok thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.