473,662 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send an Email with Outlook using VB .Net

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.Applica tion
Dim oMail As Outlook._MailIt em

oOutL = CreateObject("o utlook.applicat ion")

For i = 0 To Email.Length - 1
oMail =
oOutL.CreateIte m(Outlook.OlIte mType.olMailIte m)
oMail.UnRead = True
oMail.To = Email(i)
oMail.Subject = "My Subject"
oMail.HTMLBody = True
oMail.Body = "My Body"
oMail.Attachmen ts.Add(FilePath & "attachement.ht ml")
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
1 47468
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.Applica tion
Dim oMail As Outlook.MailIte m

oMail = oOutL.CreateIte m(Outlook.OlIte mType.olMailIte m)
oMail.UnRead = True
oMail.To = "xx*@xxx.co m"
oMail.Subject = "My Subject"
oMail.HTMLBody = True
oMail.Body = "My Body"
oMail.Attachmen ts.Add("attache ment.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.i t> wrote in message
news:31******** *************** ***@posting.goo gle.com...
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.Applica tion
Dim oMail As Outlook._MailIt em

oOutL = CreateObject("o utlook.applicat ion")

For i = 0 To Email.Length - 1
oMail =
oOutL.CreateIte m(Outlook.OlIte mType.olMailIte m)
oMail.UnRead = True
oMail.To = Email(i)
oMail.Subject = "My Subject"
oMail.HTMLBody = True
oMail.Body = "My Body"
oMail.Attachmen ts.Add(FilePath & "attachement.ht ml")
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
12076
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to use PHP to get inside an OWA (Microsoft Outlook Web Access) website to send email that way? The reason I ask is because my corporate office is going to do away with our rogue SMTP server access and force everything through Exchange
0
3695
by: David Burson | last post by:
Hi, I have a VB.NET windows app that needs to automatically send a simple text email when my users run a new version of the app for the first time. I thought this would be simple, but after days of reading posts and testing, I see it is not - unless I'm missing something? I'm not an email guru. All of my users will be running at least Windows 2000, most on XP sp2. Some of my users will have Outlook, many will be using Outlook...
0
9090
by: Akira | last post by:
Could someone tell me how to send outlook appointment email from asp page? I would like appointment email just like one outlook can send out. I tried to look for an answer for this, but it seems exchange server has to be installed on web server if I want to use the following code?? Is there way to send outlook appointment email without using outlook.Application object? If not, how can I make the code below work since we have separate...
4
7899
by: tp | last post by:
HI... I have created simple .asp page and i would like to send my page as email using my outlook . is it possible to send form body as new email outlook body using mailto command or any other way Pls help me TP
1
3044
by: Paul | last post by:
I am using a windows service which accesses Microsoft Outlook. Outlook is supposed to send an email. This works fine when not run in a windows service. I am running the service under my user domain logon. I am using VB.net and using redemption.dll to bypass the security patch. This is the line of code that causes the event error Dim olApp As New Outlook.Application When I try and use a service the following error occurs.
8
17053
by: John Brock | last post by:
I am currently using a VB.NET program to send out e-mails with plain text bodies (plus one attachment). The emails are being received as Rich Text messages (probably just my personal Outlook default, because I didn't do this in the program), but there is no actual formatting (italics, color, etc.) in the message body, which is passed to from VB.NET to Outlook as an unformatted text String. I want to start applying formatting to the...
9
77425
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
5
4092
by: pat | last post by:
Hi, i'am using an ac2K progrom which sends automaticle emails with an attachment. Since last week , a error occurs with number 2293. Our mail program is Outlook 2003. It's probably a matter of safety in outlook, but i didn't saw an answer to prevent this error on theweb. Where can i configure the safetyitem that Outlook sees the mail not langer
1
6550
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query specifies for each record... Essentially this is a make shift Ordering Tool and I want to be able to notify the receiver of the order and its specifics. q_Order_Detail_4email consists of ,,, and Example: Hello@mail.com,956,Modem,1000,xyz123...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.