Visual Basic form data export to Email Body

Posted on 2012-09-10
Last Modified: 2012-09-15
Hey guys,

I have a very basic VB form. What I want to accomplish is to export my data into the body of an email.

So, some example thoughts:

VB Form:
Ticket #
Work Performed

I want to export this data like so into my email body (Exchange)

Date: 9/10/2012                      Customer: ABC Customer
Ticket#: TKT2012-001-001

Work Performed:
Installed a Cisco router and configured the switch
Activated licenses

Any thoughts on how I can do this easily using VB 2010?

Thanks in advance!
Question by:PBXHowTos
    LVL 83

    Expert Comment

    You can set the email body to be HTML and then use a HTML table to set the proper layout.
    LVL 30

    Expert Comment

    To see how to create and send email from the WinForms application, have a look at the System.Net.Mail classes. You can build the HTML body of the email by concatenating strings as needed. For example, one can use a StringBuilder to construct the html body and use that on the MailMessage.Body property:
    body.AppendFormat("Date:{0}                      Customer: {1}", txtDate.Text, txtCustomer.Text).AppendLine()
    body.AppendFormat("Ticket#: {0}", txtTicketNo.Text).AppendLine()
    body.AppendFormat("Work Performed:").AppendLine()

    Open in new window


    Author Comment

    @MlandaT - Will that use my default email client or will it use my Outlook profile.
    LVL 30

    Accepted Solution

    That will not use anything from your default mail client or Outlook. It will just send out the email directly. You will need to provide it with the details of the mail server to use, any login information, and the from address etc. In fact, it sort of turns your WinForms app into an email client itself (only sending out emails)

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    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

    24 Experts available now in Live!

    Get 1:1 Help Now