本文介绍了在asp.net和sql server中使用gmail发送的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们正在创建一个gmail代码,它在本地主机上成功朗读但我们主持此页面并发送电子邮件这次我们收到错误plz帮助我这个代码中有什么问题

hi
we are create a gmail code and it rum successfully in local host but we are host this page and send email this time we get error plz help me what''s problem in this code

MailMessage loginInfo = new MailMessage();
loginInfo.To.Add(txt_email.Text.ToString());
loginInfo.From = new MailAddress("my email id");
loginInfo.Subject = "Contact Detail";
loginInfo.Body = "Message: " + txt_message.Text; 
loginInfo.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("my user name", "My password");
smtp.Send(loginInfo);

推荐答案

loginInfo.To.Add(txt_email.Text.ToString());
loginInfo.From = new MailAddress("my email id");







但TO Adrress需要New MailAddress( )对象代替FROM。




But the TO Adrress requires the New MailAddress() object in stead of the FROM.


这篇关于在asp.net和sql server中使用gmail发送的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 09:01