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
  1. Home
  2. General Programming
  3. Visual Basic
  4. send email

send email

Scheduled Pinned Locked Moved Visual Basic
questioncsharpcomsysadmin
5 Posts 5 Posters 0 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.
  • A Offline
    A Offline
    angels777
    wrote on last edited by
    #1

    i am new to vb.net. i would like to create a class for sending emial . i tried the script online but i failed to send. So i got this code below from the hosting server. May i know how do i simplify the below script to just receive FromEmail, Subject, Message ? why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ? Please kindly advice. thanks <pre> ' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) *** function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL) on error resume next dim Mailer set Mailer = server.createobject("CDO.Message") if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if Mailer.From = FromName & " <" & FromEmail & ">" Mailer.To = ToName & " <" & ToEmail & ">" Mailer.TextBody = Message Mailer.Subject = Subject with Mailer.Configuration .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1 .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com" .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword" .Fields.Update end with Mailer.Send if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if set Mailer = Nothing CDOSYS_Mailer = true end function</pre>

    C L C 3 Replies Last reply
    0
    • A angels777

      i am new to vb.net. i would like to create a class for sending emial . i tried the script online but i failed to send. So i got this code below from the hosting server. May i know how do i simplify the below script to just receive FromEmail, Subject, Message ? why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ? Please kindly advice. thanks <pre> ' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) *** function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL) on error resume next dim Mailer set Mailer = server.createobject("CDO.Message") if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if Mailer.From = FromName & " <" & FromEmail & ">" Mailer.To = ToName & " <" & ToEmail & ">" Mailer.TextBody = Message Mailer.Subject = Subject with Mailer.Configuration .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1 .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com" .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword" .Fields.Update end with Mailer.Send if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if set Mailer = Nothing CDOSYS_Mailer = true end function</pre>

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      .NET has its own built in ways of sending mail. You want to read MSDN and look up the System.Net.Mail namespace and specifically the SmtpClient[^] class.

      Developer Day Scotland 2 - Free community conference Recent blog posts: *Throwing Exceptions *Training Developers * Method hiding or overriding - or the difference between new and virtual

      1 Reply Last reply
      0
      • A angels777

        i am new to vb.net. i would like to create a class for sending emial . i tried the script online but i failed to send. So i got this code below from the hosting server. May i know how do i simplify the below script to just receive FromEmail, Subject, Message ? why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ? Please kindly advice. thanks <pre> ' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) *** function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL) on error resume next dim Mailer set Mailer = server.createobject("CDO.Message") if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if Mailer.From = FromName & " <" & FromEmail & ">" Mailer.To = ToName & " <" & ToEmail & ">" Mailer.TextBody = Message Mailer.Subject = Subject with Mailer.Configuration .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1 .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com" .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword" .Fields.Update end with Mailer.Send if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if set Mailer = Nothing CDOSYS_Mailer = true end function</pre>

        L Offline
        L Offline
        LloydA111
        wrote on last edited by
        #3

        Dim message As New MailMessage("sender@address", "from@address", "Subject", "Message Text") Dim emailClient As New SmtpClient("Email Server Name") emailClient.Send(message) That will do the job. However, this code is one of the snippets in Visual basic, so how you didnt find it I dont know :doh: . And its not that hard to search google for this, and for possibly more reliable results try MSDN.

        Lloyd J. Atkinson

        1 Reply Last reply
        0
        • A angels777

          i am new to vb.net. i would like to create a class for sending emial . i tried the script online but i failed to send. So i got this code below from the hosting server. May i know how do i simplify the below script to just receive FromEmail, Subject, Message ? why it needs the mailerpath?mailerport? and errText? isn't we can check those error in the form instead of class ? Please kindly advice. thanks <pre> ' **** MailerPath = Your SMTP path (for eg: mail.[domain].com) *** function CDOSYS_Mailer(Message, FromEmail, ToEmail, FromName, ToName, Subject, MailerPath, MailerPort, errText, searchURL) on error resume next dim Mailer set Mailer = server.createobject("CDO.Message") if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if Mailer.From = FromName & " <" & FromEmail & ">" Mailer.To = ToName & " <" & ToEmail & ">" Mailer.TextBody = Message Mailer.Subject = Subject with Mailer.Configuration .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailerPath .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailerPort .Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1 .Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")="test@yourdomain.com" .Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")="youremailpassword" .Fields.Update end with Mailer.Send if err.number <> 0 then errText = displayError("CDOSYS", searchURL, err.Number, err.Source, err.Description) CDOSYS_Mailer = false : set Mailer = nothing : err.clear() : err = 0 exit function end if set Mailer = Nothing CDOSYS_Mailer = true end function</pre>

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You won't learn VB.NET by trying to copy code snippets off the web that you don't understand. This is a TERRIBLE way to send mail, as others said, the mail classes are built in. I would recommend reading my article on how to use google, it actually uses sending an email as an example. I would also recommend buying a book and working through it, learning how to program VB.NET incrementally instead of trying to learn how to copy and paste other people's code that is above your head.

          Christian Graus Driven to the arms of OSX by Vista.

          A 1 Reply Last reply
          0
          • C Christian Graus

            You won't learn VB.NET by trying to copy code snippets off the web that you don't understand. This is a TERRIBLE way to send mail, as others said, the mail classes are built in. I would recommend reading my article on how to use google, it actually uses sending an email as an example. I would also recommend buying a book and working through it, learning how to program VB.NET incrementally instead of trying to learn how to copy and paste other people's code that is above your head.

            Christian Graus Driven to the arms of OSX by Vista.

            A Offline
            A Offline
            astanton1978
            wrote on last edited by
            #5

            http://letmegooglethatforyou.com/[^] =)

            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