Sending Email

Posted on 2006-04-06
Last Modified: 2010-04-23
I have a application that I need to send an email, with attachment. I'm not sure on which approach to take. I found some code online that worked, but it uses outlook to send the message. But, this application will be distributed to many clients. Is there a way to send an email and have the email message sent using any default mail client? For instance, MAPI, etc?
Question by:Gary2397
    LVL 62

    Expert Comment

    by:Fernando Soto
    Hi Gary2397;

    This code should use the default SMTP server.

    Imports System.Web.Mail

            ' Send the message
            _Message = New MailMessage
            With _Message
                .From = txtFrom.Text
                .To = txtTo.Text
                .Subject = txtSubject.Text
                If rbHTML.Checked Then
                    .BodyFormat = MailFormat.Html
                    .BodyFormat = MailFormat.Text
                End If
                .Body = txtMessage.Text
                ' Attaching a test file
                .Attachments.Add(New MailAttachment("C:\Temp\txt1.txt"))
            End With


    Author Comment

    Will this send the email directly? Or, if the user has Outlook, by default,will this send to the outbox. If the user is using Outlook, I need to be able to send to outbox.
    LVL 48

    Accepted Solution


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    754 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

    18 Experts available now in Live!

    Get 1:1 Help Now