Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

VB
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.
Posted
Updated 28-May-10 19:52pm
v2

Have you checked all these things[^]
 
Share this answer
 
Please try the following:
C#
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
XML
<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" />
 
Share this answer
 
v2
Comments
Sandeep Mewara 29-May-10 1:57am    
Reason for my vote of 1
You have suggested SMTPClient code, that was not available in 1.1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900