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. C#
  4. Send an email from a Form?

Send an email from a Form?

Scheduled Pinned Locked Moved C#
questionsysadminhelplearning
7 Posts 4 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.
  • B Offline
    B Offline
    Bog
    wrote on last edited by
    #1

    Hi this is kind of an embarassing question- do I actually need to run an SMTP server to send an email? What I want to do is have my desktop windows app (Form) send an email when the user clicks a button. If the user installs my app, do I need to also install an SMTP sever on the user's local machine? I've read a lot about using the System.Web.Mail stuff. But I'm getting the "Could not access 'CDO.Message' object." error when I set SmtpMail.SmtpServer="localhost". I tried all the suggested fixes- I have Outlook installed, I'm using valid addresses for To and From, I tried setting SmtpMail.SmtpServer to "". Do I have to install an SMTP server on the user's machine in order to send an email? thanks "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

    D N M 3 Replies Last reply
    0
    • B Bog

      Hi this is kind of an embarassing question- do I actually need to run an SMTP server to send an email? What I want to do is have my desktop windows app (Form) send an email when the user clicks a button. If the user installs my app, do I need to also install an SMTP sever on the user's local machine? I've read a lot about using the System.Web.Mail stuff. But I'm getting the "Could not access 'CDO.Message' object." error when I set SmtpMail.SmtpServer="localhost". I tried all the suggested fixes- I have Outlook installed, I'm using valid addresses for To and From, I tried setting SmtpMail.SmtpServer to "". Do I have to install an SMTP server on the user's machine in order to send an email? thanks "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

      D Offline
      D Offline
      David Stone
      wrote on last edited by
      #2

      Bog wrote: Do I have to install an SMTP server on the user's machine in order to send an email? No...you just need to point to the user's SMTP server at their ISP...


      I passionately hate the idea of being with it, I think an artist has always to be out of step with his time. -Orson Welles

      B 1 Reply Last reply
      0
      • B Bog

        Hi this is kind of an embarassing question- do I actually need to run an SMTP server to send an email? What I want to do is have my desktop windows app (Form) send an email when the user clicks a button. If the user installs my app, do I need to also install an SMTP sever on the user's local machine? I've read a lot about using the System.Web.Mail stuff. But I'm getting the "Could not access 'CDO.Message' object." error when I set SmtpMail.SmtpServer="localhost". I tried all the suggested fixes- I have Outlook installed, I'm using valid addresses for To and From, I tried setting SmtpMail.SmtpServer to "". Do I have to install an SMTP server on the user's machine in order to send an email? thanks "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

        N Offline
        N Offline
        Nick Seng
        wrote on last edited by
        #3

        Here's an idea, if you have Outlook installed in the user's machine, why not just use the Outlook Com object.Add a reference to the Com, and add the following code:

        Outlook.Application ol = new Outlook.Application();
        Outlook.MailItem ml;
        ml = ol.CreateItem(olMailItem);
        
        ml.Body = "message body";
        ml.To = email address;
        ml.SenderName = your email;
        ml.Send();
        

        warning: the code above is modified from vba, so it might not exactly like expected.


        God, I pity me! - Phoncible P. Bone If I end up Windows ME someone is going to be hurting. - One of the answers to a question for What OS are you

        B 1 Reply Last reply
        0
        • B Bog

          Hi this is kind of an embarassing question- do I actually need to run an SMTP server to send an email? What I want to do is have my desktop windows app (Form) send an email when the user clicks a button. If the user installs my app, do I need to also install an SMTP sever on the user's local machine? I've read a lot about using the System.Web.Mail stuff. But I'm getting the "Could not access 'CDO.Message' object." error when I set SmtpMail.SmtpServer="localhost". I tried all the suggested fixes- I have Outlook installed, I'm using valid addresses for To and From, I tried setting SmtpMail.SmtpServer to "". Do I have to install an SMTP server on the user's machine in order to send an email? thanks "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

          M Offline
          M Offline
          Manster
          wrote on last edited by
          #4

          This url http://www.c-sharpcorner.com/Internet/MailingAppMG.asp should help you, it worked for me. ;)

          B 1 Reply Last reply
          0
          • M Manster

            This url http://www.c-sharpcorner.com/Internet/MailingAppMG.asp should help you, it worked for me. ;)

            B Offline
            B Offline
            Bog
            wrote on last edited by
            #5

            Yea this is exactly what I did, and I got the error I described. But thanks for your response anyway. "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

            1 Reply Last reply
            0
            • N Nick Seng

              Here's an idea, if you have Outlook installed in the user's machine, why not just use the Outlook Com object.Add a reference to the Com, and add the following code:

              Outlook.Application ol = new Outlook.Application();
              Outlook.MailItem ml;
              ml = ol.CreateItem(olMailItem);
              
              ml.Body = "message body";
              ml.To = email address;
              ml.SenderName = your email;
              ml.Send();
              

              warning: the code above is modified from vba, so it might not exactly like expected.


              God, I pity me! - Phoncible P. Bone If I end up Windows ME someone is going to be hurting. - One of the answers to a question for What OS are you

              B Offline
              B Offline
              Bog
              wrote on last edited by
              #6

              This is a new one- I haven't seen anyone mention this. If the use doesn't have outlook installed, then obviously this won't work. So I'm still probably better off installing an SMTP server on the users local machine instead. Hey, if the user has Outlook installed, but the user didn't specify an SMTP server for outlook (or specified an incorrect one), then this won't work right? Or is it like using the underlying internal SMTP server of outlook itself or something? See, like me for example- I have outlook installed but I never use it- I use Eudora, so I never told Outlook what SMTP server to use. thanks for your response, "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

              1 Reply Last reply
              0
              • D David Stone

                Bog wrote: Do I have to install an SMTP server on the user's machine in order to send an email? No...you just need to point to the user's SMTP server at their ISP...


                I passionately hate the idea of being with it, I think an artist has always to be out of step with his time. -Orson Welles

                B Offline
                B Offline
                Bog
                wrote on last edited by
                #7

                Well, thanks but that won't do. I have verizon, for examle, and Verizon doesn't let you send email where the From address is anything besides the email address verizon gives you. If you want to send email From any other address you have to use a different SMTP server. Also where could I find out what the user's ISP's SMTP server is? Like if they don't have Outlook installed, or it's not set up (wrong or missing SMTP for example). thanks anyway for your response. "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx

                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