Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Email issue

Email issue

Scheduled Pinned Locked Moved C#
helphtml
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    damar1r
    wrote on last edited by
    #1

    when i try to send an email it give me the following error: "Could not access 'CDO.Message' object" My code was: EmailForm frm = new EmailForm(); if(frm.ShowDialog() == DialogResult.OK) { frm = null; MailMessage mailObj = new MailMessage(); mailObj.From ="ME"; mailObj.To = to; mailObj.Cc = cc; mailObj.Bcc = bcc; mailObj.Subject = subject; MailAttachment mailAtt = new MailAttachment(Path); mailObj.Attachments.Add(mailAtt); mailObj.Body = "Body Text!!!"; mailObj.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = Dns.GetHostName(); try { SmtpMail.Send(mailObj); } catch(Exception ex) { MessageBox.Show(ex.Message,"Error"); } } Can u help me on this. thanks.

    C 1 Reply Last reply
    0
    • D damar1r

      when i try to send an email it give me the following error: "Could not access 'CDO.Message' object" My code was: EmailForm frm = new EmailForm(); if(frm.ShowDialog() == DialogResult.OK) { frm = null; MailMessage mailObj = new MailMessage(); mailObj.From ="ME"; mailObj.To = to; mailObj.Cc = cc; mailObj.Bcc = bcc; mailObj.Subject = subject; MailAttachment mailAtt = new MailAttachment(Path); mailObj.Attachments.Add(mailAtt); mailObj.Body = "Body Text!!!"; mailObj.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = Dns.GetHostName(); try { SmtpMail.Send(mailObj); } catch(Exception ex) { MessageBox.Show(ex.Message,"Error"); } } Can u help me on this. thanks.

      C Offline
      C Offline
      CodyGen
      wrote on last edited by
      #2

      This could be an authentication issue. Try providing more details to the account you want to use to send the email. I have found this from Microsoft and it helped me. You may want to try it too: try { string smtpServer = "mail.mystmpserver.com"; //your smtp server here userName = "myaccount@mystmpserver.com; //your account info here password = "mypassword"; //your password int cdoBasic = 1; int cdoSendUsingPort = 2; MailMessage mail = new MailMessage(); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25) ; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort) ; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password); mail.To = "emailaddress@server.com" ; // if you want to send it to multiple email address separate them using semicolon mail.From = "emailaddress2@server.com" ; mail.Subject = "Subject here"; mail.Attachments.Add("file here"); mail.BodyFormat = MailFormat.Html; mail.Body = "This is a bold text in the body of the mail." SmtpMail.SmtpServer=smtpServer; SmtpMail.Send( mail ); Label1.Text="Message Sending successful"; } catch(Exception ex) { Label1.Text="Message Sending failed! Error: " + strerror ; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups