• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 796
  • Last Modified:

visual studio to send html email

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
motokent
Asked:
motokent
1 Solution
 
motokentAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now