使用ASP.NET1.1发送电子邮件时出错 [英] Error while sending an email using ASP.NET1.1

查看:115
本文介绍了使用ASP.NET1.1发送电子邮件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



文件上传成功后,我想发送一封简单的电子邮件.文件已成功上传,但未发送邮件.错误消息为无法访问"CDO.Message"对象".以下是我使用的代码.

Hi,

I want to send a simple email when a file upload is successful. The file is getting uploaded successfully but the mail is not sent. The error message is "Could not access ''CDO.Message'' object". Below is the code I used.

Imports System.Web.Mail

Dim ObjMail As New MailMessage
ObjMail.From = "xxxx@gmail.com"
ObjMail.To = "yyyy@gmail.com"
ObjMail.Body = "A file is ready for review"
SmtpMail.SmtpServer = "smtp.gmail.com"

Try
   SmtpMail.Send(ObjMail)
   Response.Write("Email sent successfully")

Catch Exc As Exception
   Response.Write("Error:Mail Sendng " & Exc.Message)
End Try


请帮助我确定问题并解决.


Please help me to identify the problem and to solve it.

推荐答案

您是否已检查所有这些 ^ ]
Have you checked all these things[^]


请尝试以下操作:
Please try the following:
public static void SendMailMessage(string smtpHost, MailAddress from, string to, string subject, string message, MailPriority Priority, Encoding Encode)
        {
            try
            {
                MailMessage mailMsg = new MailMessage();
                result = to.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                for (int count = 0; count < result.Length; count++)
                { mailMsg.To.Add(new MailAddress(result[count])); }
                mailMsg.From = from;
                mailMsg.Subject = subject;
                mailMsg.Body = message;
                mailMsg.Priority = Priority;
                mailMsg.BodyEncoding = Encode;
                SmtpClient smtpClient = new SmtpClient(smtpHost);
                smtpClient.Send(mailMsg);
            }
            catch (Exception)
            {
            }
        }


从配置文件读取的参数值如下


Parameter Value reading from config file are as follows

<add key="Email.Recipient" value="John.Smith@abc.com, Joe.Wilson@abc.com" />
      <add key="Email.Sender" value="Bob.Jones@xyz.com " />
      <add key="Email.Copy" value="mycclist@xyz.com" />
      <add key="Email.Priority" value="MailPriority.Normal "/>
      <add key="Email.Encoding" value="Encoding.ASCII"/>
      <add key="Email.Subject" value=".NET Email Utility Sample"/>
      <add key="Email.Message" value="This email provides an example of sending a .NET email using C#."/>
      <add key="Email.Smtp" value="mailhost.xyz.com" />


这篇关于使用ASP.NET1.1发送电子邮件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆