Solved

visual studio to send html email

Posted on 2011-02-23
1
785 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

747 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

10 Experts available now in Live!

Get 1:1 Help Now