Solved

visual studio to send html email

Posted on 2011-02-23
1
786 Views
Last Modified: 2012-05-11
I have a visual basic application that generates a report in html format.  So far, so good.

Now I want the user to have the option to email the page.  I am using a linklabel.

Two things:
--When I use the full html, I get an error "Cannot start Microsoft Office Outlook.  The command line argument is not valid.  Verify the switch you are using."
--When I scale back the html to a very simple page, Outlook opens the right way, but the html is printed out rather than displaying like a webpage.

Am I trying something that cannot be done?
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim HTML As String = My.Computer.FileSystem.ReadAllText(MyTmp & "\Daily.html")
        Process.Start("mailto:anyone@somewhere.com?subject=test&content-type=text/html&body=" & HTML)
    End Sub

Open in new window

0
Comment
Question by:motokent
1 Comment
 

Accepted Solution

by:
motokent earned 0 total points
ID: 34965582
I found the answer here:
http://www.techrepublic.com/article/easily-automate-microsoft-outlook-via-net/5850937

Dim app As Microsoft.Office.Interop.Outlook.Application
Dim appNameSpace As Microsoft.Office.Interop.Outlook._NameSpace
Dim memo As Microsoft.Office.Interop.Outlook.MailItem
Dim outbox As Microsoft.Office.Interop.Outlook.MAPIFolder
Try
app = New Microsoft.Office.Interop.Outlook.ApplicationappNameSpace = app.GetNamespace("MAPI")appNameSpace.Logon(Nothing, Nothing, False, False)
memo = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)memo.To = "Anthony.Patton@Ingenix.com" memo.Subject = "TechRepublic.com Test"memo.Body = "Hello there"memo.Send()
Catch ex As COMExceptionConsole.WriteLine(ex.ToString())
End Try

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Read this checklist to learn more about the 15 things you should never include in an email signature.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 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

21 Experts available now in Live!

Get 1:1 Help Now