栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

我如何在电子邮件中发送HTML表单..不只是MAILTO

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

我如何在电子邮件中发送HTML表单..不只是MAILTO

实际上,我现在使用ASP C#发送电子邮件,内容类似于:

protected void Page_Load(object sender, EventArgs e){    if (Request.Form.Count > 0)    {        string formEmail = "";        string fromEmail = "from@email.com";        string defaultEmail = "default@email.com";        string sendTo1 = "";        int x = 0;        for (int i = 0; i < Request.Form.Keys.Count; i++)        { formEmail += "<strong>" + Request.Form.Keys[i] + "</strong>"; formEmail += ": " + Request.Form[i] + "<br/>"; if (Request.Form.Keys[i] == "Email") {     if (Request.Form[i].ToString() != string.Empty)     {         fromEmail = Request.Form[i].ToString();     }     formEmail += "<br/>"; }        }        System.Net.Mail.MailMessage myMsg = new System.Net.Mail.MailMessage();        SmtpClient smtpClient = new SmtpClient();        try        { myMsg.To.Add(new System.Net.Mail.MailAddress(defaultEmail)); myMsg.IsBodyHtml = true; myMsg.Body = formEmail; myMsg.From = new System.Net.Mail.MailAddress(fromEmail); myMsg.Subject = "Sent using Gmail Smtp"; smtpClient.Host = "smtp.gmail.com"; smtpClient.Port = 587; smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = true; smtpClient.Credentials = new System.Net.NetworkCredential("testing@gmail.com", "pward"); smtpClient.Send(defaultEmail, sendTo1, "Sent using gmail smpt", formEmail);        }        catch (Exception ee)        { debug.Text += ee.Message;        }    }}

这是使用gmail作为smtp邮件发件人的示例。这里不需要其中的某些内容,但这是我的使用方式,因为我敢肯定,以相同的方式有更有效的方法。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/575495.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号