当前位置: 首页>>代码示例>>C#>>正文


C# Email.send_html方法代码示例

本文整理汇总了C#中Email.send_html方法的典型用法代码示例。如果您正苦于以下问题:C# Email.send_html方法的具体用法?C# Email.send_html怎么用?C# Email.send_html使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Email的用法示例。


在下文中一共展示了Email.send_html方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendContactMessage

        public bool SendContactMessage(string name , string email, string phone, string location, string message)
        {
            string path = HttpContext.Current.Server.MapPath("~" + ConfigurationManager.AppSettings["savedmessagepath"] +
                        String.Format("{0:s}", DateTime.Now).Replace('T', '_').Replace(':', '-') + ".txt");
            try
            {

                StringBuilder sbBody = new StringBuilder();
                sbBody.Append(" Dear Admin," + Environment.NewLine);
                sbBody.Append(string.Format("A user with the following name {0}, number {1} and location {2}." + Environment.NewLine, name, phone, location));
                sbBody.Append("Has sent the following message." + Environment.NewLine);
                sbBody.Append("----------------------------------------------------------------" + Environment.NewLine + message + Environment.NewLine);

                

                //persist message in file
                using (TextWriter writer = File.CreateText(path))
                {
                    writer.WriteLine(sbBody.ToString());
                }

                Email mail = new Email(EmailConstants.SMTPServer, EmailConstants.AdminEmail, EmailConstants.AdminPass);
                
                return mail.send_html(EmailConstants.AdminEmail, EmailConstants.AdminName, email, name, "[Global Service Security] - New Enquriy", sbBody.ToString());
            }
            catch(Exception ex) {
                using (TextWriter writer = File.CreateText(path))
                {
                    writer.WriteLine("Email sent failed." + ex.Message);
                } 
                return false; 
            }
        }
开发者ID:Cmadmin,项目名称:globalservicesecurity.com,代码行数:33,代码来源:MessagingService.cs


注:本文中的Email.send_html方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。