How to send email from VB.Net using a mail template
If you know how to use the Microsoft Outlook Object Library 14, you can make your life more easy.
How about creating an email, based on some template? Here's the way to do it:
First add a reference to the Microsoft Outlook Object Library 14 (assuming you use MS Outlook 10).
Second add an import-statement on the top of your file:
Imports Outlook = Microsoft.Office.Interop.Outlook
Finally, use the following code:
Dim myOlApp As New Outlook.Application
Dim MyMail As Outlook.MailItem = myOlApp.CreateItemFromTemplate("c:\Temp\MyTemplate.oft", Outlook.OlItemType.olMailItem)
Dim myRecipients As Outlook.Recipients Dim myRecipient As Outlook.Recipient myOlApp = CreateObject("Outlook.Application") MyMail = myOlApp.CreateItem(Outlook.OlItemType.olMailItem) myRecipients = MyItem.Recipients
myRecipients.Add("
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
This e-mail address is being protected from spambots. You need JavaScript enabled to view it ")
MyMail.Body = "Dit is een test" MyMail.Subject = "TestOnderwerp" MyMail.Send()
|