By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,024 Members | 2,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,024 IT Pros & Developers. It's quick & easy.

Send an Email with Outlook using VB .Net

P: n/a
Hi,
I need to send the same Email to different people. I'm using Outlook
XP and VB.Net. I tryed with the following code:

Dim oOutL As Outlook.Application
Dim oMail As Outlook._MailItem

oOutL = CreateObject("outlook.application")

For i = 0 To Email.Length - 1
oMail =
oOutL.CreateItem(Outlook.OlItemType.olMailItem)
oMail.UnRead = True
oMail.To = Email(i)
oMail.Subject = "My Subject"
oMail.HTMLBody = True
oMail.Body = "My Body"
oMail.Attachments.Add(FilePath & "attachement.html")
oMail.Send()
Next

but all i got is an Email without my name on it in the "FROM" field,
how can i add it?

another solution that I thought for send those Emails is to manually
create the Email and save it in the local disk and with VB.NET just
open it, paste the mail address in the "TO" field and send it, but I
don't know how open an Email from the code.

Can you help me?

Thanks

Michele
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Michele,
In addition to OHM's suggestion of using the System.Web.Mail namespace,
which for simply sending emails is much easier.

Do you have the XP PIA installed? See "Office XP Primary Interop Assembly"
at the url below.

The following code works with Outlook 2003 with the Outlook 2003 PIA
installed, of course it is subject to the Outlook security prompts.

Dim oOutL As New Outlook.Application
Dim oMail As Outlook.MailItem

oMail = oOutL.CreateItem(Outlook.OlItemType.olMailItem)
oMail.UnRead = True
oMail.To = "xx*@xxx.com"
oMail.Subject = "My Subject"
oMail.HTMLBody = True
oMail.Body = "My Body"
oMail.Attachments.Add("attachement.html")
oMail.Send()
Return

The following site contains a plethora of articles on using Outlook with
..NET:

http://www.microeye.com/resources/res_outlookvsnet.htm

To avoid the Outlook security prompts its generally easiest to create a
properly constructed COM-Addin for Outlook 2003. There are other methods
available for other versions of Outlook...

Hope this helps
Jay

"Michele" <mi****@tin.it> wrote in message
news:31**************************@posting.google.c om...
Hi,
I need to send the same Email to different people. I'm using Outlook
XP and VB.Net. I tryed with the following code:

Dim oOutL As Outlook.Application
Dim oMail As Outlook._MailItem

oOutL = CreateObject("outlook.application")

For i = 0 To Email.Length - 1
oMail =
oOutL.CreateItem(Outlook.OlItemType.olMailItem)
oMail.UnRead = True
oMail.To = Email(i)
oMail.Subject = "My Subject"
oMail.HTMLBody = True
oMail.Body = "My Body"
oMail.Attachments.Add(FilePath & "attachement.html")
oMail.Send()
Next

but all i got is an Email without my name on it in the "FROM" field,
how can i add it?

another solution that I thought for send those Emails is to manually
create the Email and save it in the local disk and with VB.NET just
open it, paste the mail address in the "TO" field and send it, but I
don't know how open an Email from the code.

Can you help me?

Thanks

Michele

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.