Auto se3nding email in VB.NET

Posted on 2006-05-01
Last Modified: 2010-04-23
I have a need to automatically send an email from my Windows form.  Note that this is not a web form (aspx).

In ASP.NET I can use  a SmtpMail.Send(Message) command.  What do I have to do similarily in a VB.Net windows form?

Question by:robertjmackay
    LVL 7

    Expert Comment

    The same way. Like so:

                Dim eml As New MailMessage
                eml.To = ""
                eml.From = ""
                eml.Subject = "Free money!"
                eml.Body = "He should give us all a dollar."

                Dim smtp As SmtpMail
                smtp.SmtpServer = ""

    Author Comment

    When I added the imports system.web.mail statement, I get a compiler error.  Am I missing something
    LVL 7

    Accepted Solution

    I've noticed this issue too. Try this:

    In your References (Solution Explorer), make sure System.Web is added. If not, right click References, Add Reference, scroll down to System.Web.

    Tell me what happens.

    Author Comment

    well done, thanks

    Rob MacKay

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now