- Joined
- Feb 17, 2012
- Messages
- 4
- Reaction score
- 0
Hi,
I am trying to use this code in access 2010 to send a simple test mail
Public Function cmdMail()
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMailItem As Outlook.MailItem
Dim objRecipient As Outlook.Recipient
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMailItem = objOutlook.CreateItem(olMailItem)
Set objRecipient = objMailItem.Recipients.Add("me")
objRecipient.Type = olTo
Set objRecipient = objMailItem.Recipients.Add("you")
objRecipient.Type = olCC
objMailItem.Subject = "June 2002 Financial Analysis"
objMailItem.Body = "Hi, hope all's well. Here's the financial analysis. Regards JP"
objNameSpace.LogOn , , True
objMailItem.Display
Set objRecipient = Nothing
Set objMailItem = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
End Function
however when i step through it i get an application deined or object defined error at this line
Set objRecipient = objMailItem.Recipients.Add("me")
could someone help me please
I am trying to use this code in access 2010 to send a simple test mail
Public Function cmdMail()
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMailItem As Outlook.MailItem
Dim objRecipient As Outlook.Recipient
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMailItem = objOutlook.CreateItem(olMailItem)
Set objRecipient = objMailItem.Recipients.Add("me")
objRecipient.Type = olTo
Set objRecipient = objMailItem.Recipients.Add("you")
objRecipient.Type = olCC
objMailItem.Subject = "June 2002 Financial Analysis"
objMailItem.Body = "Hi, hope all's well. Here's the financial analysis. Regards JP"
objNameSpace.LogOn , , True
objMailItem.Display
Set objRecipient = Nothing
Set objMailItem = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
End Function
however when i step through it i get an application deined or object defined error at this line
Set objRecipient = objMailItem.Recipients.Add("me")
could someone help me please