473,763 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending emails using vb with outlook

I found this code below to use to send emails using VB with Outlook.
However, it gives these errors.

'Send' is ambiguous across the inherited interfaces 'Outlook._MailI tem' and
'Outlook.ItemEv ents_Event'.
Name 'olByReference' is not declared.
Name 'olMailItem' is not declared.
Name 'olTo' is not declared.

How could i edit this code to get it to work?

Any suggestions would be greatly appreciated!!

Nicole
Sub NewMailMessage( )
Dim ol As New Outlook.Applica tion
Dim ns As Outlook.NameSpa ce
Dim newMail As Outlook.MailIte m

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace ("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(o lMailItem)
With newMail
'Add the subject of the mail message.
.Subject = "Test"
'Create some body text.
.Body = "Test"

'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add ("mi****@imginc .com")
.Type = olTo
If Not .Resolve Then
MsgBox "Unable to resolve address.", vbInformation
Exit Sub
End If
End With

'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub
Nov 20 '05 #1
4 4572
Have you added referances to the outlook office classes, if you go to the project add referances you will see the office objects.
Nov 20 '05 #2
Imports System.Web.Mail

Dim msg As New Web.Mail.MailMe ssage()

SmtpMail.SmtpSe rver = "yourmailserver namehere"

msg.From = "fr**@from. com"

msg.To = "to@to.com"

msg.Subject = "Subject"

msg.Body = "Body"

SmtpMail.Send(m sg)

"Nicole" <nm****@bellsou th.net> wrote in message
news:6D******** ***********@big news2.bellsouth .net...
I found this code below to use to send emails using VB with Outlook.
However, it gives these errors.

'Send' is ambiguous across the inherited interfaces 'Outlook._MailI tem' and 'Outlook.ItemEv ents_Event'.
Name 'olByReference' is not declared.
Name 'olMailItem' is not declared.
Name 'olTo' is not declared.

How could i edit this code to get it to work?

Any suggestions would be greatly appreciated!!

Nicole
Sub NewMailMessage( )
Dim ol As New Outlook.Applica tion
Dim ns As Outlook.NameSpa ce
Dim newMail As Outlook.MailIte m

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace ("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(o lMailItem)
With newMail
'Add the subject of the mail message.
.Subject = "Test"
'Create some body text.
.Body = "Test"

'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add ("mi****@imginc .com")
.Type = olTo
If Not .Resolve Then
MsgBox "Unable to resolve address.", vbInformation
Exit Sub
End If
End With

'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub

Nov 20 '05 #4
Nicole,
It sounds like you have an older version of Outlook.

If you have Outlook XP or Outlook 2003, there are PIA's that are available
that make using Outlook from .NET easier.

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

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

I believe your specific problem will be addressed with the section titled
"Rebuilding the Outlook Interop Assembly" if you are not able to upgrade to
Outlook XP or Outlook 2003.

If you have Outlook XP or Outlook 2003 then I would suggest you install the
respective PIA.

Hope this helps
Jay

"Nicole" <nm****@bellsou th.net> wrote in message
news:6D******** ***********@big news2.bellsouth .net...
I found this code below to use to send emails using VB with Outlook.
However, it gives these errors.

'Send' is ambiguous across the inherited interfaces 'Outlook._MailI tem' and 'Outlook.ItemEv ents_Event'.
Name 'olByReference' is not declared.
Name 'olMailItem' is not declared.
Name 'olTo' is not declared.

How could i edit this code to get it to work?

Any suggestions would be greatly appreciated!!

Nicole
Sub NewMailMessage( )
Dim ol As New Outlook.Applica tion
Dim ns As Outlook.NameSpa ce
Dim newMail As Outlook.MailIte m

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace ("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(o lMailItem)
With newMail
'Add the subject of the mail message.
.Subject = "Test"
'Create some body text.
.Body = "Test"

'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add ("mi****@imginc .com")
.Type = olTo
If Not .Resolve Then
MsgBox "Unable to resolve address.", vbInformation
Exit Sub
End If
End With

'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3229
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using this, it seems, that the user must install IIS on their computer. Isn't there a class that will detect whatever mail server is available on a computer and use that? How do I create this functionality without having the user add any other...
0
1452
by: ifeoma | last post by:
I have a script which sends emails through Access. It sends these emails as if it was sent through Outlook. I had no problem with this using Office 2000 but with the newer Outlook 2002 it asks if I want to send the email (Yes/No/Cancel). And sometimes you don't see it asking you this. How do I tell Outlook 2002 to send it without asking? Thanks, Chris
2
9241
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends - I see hebrew, it is just sending by myself using *.aspx scripts). In web.config I have the following : <configuration> <system.web>
8
4381
by: Frank | last post by:
I think I've confused myself completely here :-) I have used System.Web.Mail, but am not sure if this works with Exchange Server 5.5. I asked the client if they're email server supported SMTP, and got the following reply (exact quote): Exchange 5.5 uses IMS connector for communication between the internal and the external world. IMS is based on SMTP Protocol. For mail flow within the organization Exchange 5.5 uses Message Transfer...
5
2977
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
5
1618
by: Richard Kure | last post by:
I encountered a problem sending an email on my windows XP, which I thought was a bit weird, cause it worked for me before on windows XP. So I tried on some other computers with windows XP, and managed to send emails on the systems where outlook was not installed. So I'm pretty sure the problem lies in outlook using exchange server. Does anyone know how to solve this, maybe send the mail to the exchange server or outlook instead. I dont...
2
2011
by: Jodye Roebuck | last post by:
I have a program that's been automatically generating and sending emails flawlessly. My clients workstation had an automatic Microsoft security update done on it.. and now it's bombing on this line : lobjMessage.SEND(0,0,0) Apparently, the security patch doesn't allow external programs/utilities to SEND Outlook emails. The emails are saved and can be manually sent out later, but this is obviously not how it's intended to be used.
7
9343
by: mlevit | last post by:
Hi, I send out emails through MS Access via SendObject. I would like to know if there is a way of getting rid of the Outlook Security Popup that comes up every time an email is about to be sent. I have tried Advanced Security For Outlook but it does not seem to popup when sending emails, I’ve used it before for synchronization with my mobile, and it seemed to popup then. Any help would be greatly appreciated
6
9794
by: ssankar | last post by:
hi all - I have been tasked to send customized emails to a set of users based on a certain condition in my company. ( This is NOT SPAM ) I have used MIME::Lite successfully to send html templates as emails. the users in my company are Outlook users. But for some reason my emails sometimes reach the Junk E-Mail folder( I am sending using my own company issued email address ) Here's the code I currently use: #!/usr/bin/perl -w use...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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
5270
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...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.