I need some Redemption

D

Daniel Lamarche

Hello. I would like soo much to be able to send an email properly with
Redemption installed in the Reference.
I'm in Access 2000. When I try this code I get an error message saying
"Could not resolve the message recipient."
Of course Daniel Lamarche is one of the Contact. The same happens if I use
an email address instead of the contact name. For instance
MailItemObject.Recipients.Add ([email protected])


Public Sub SendMailAgain()
Dim olApp As Outlook.Application
Dim olMailItemObject As Outlook.MailItem
Dim SafeMailItem As Redemption.SafeMailItem
Dim ns As Outlook.NameSpace

Set olApp = CreateObject("Outlook.application")
Set ns = olApp.GetNamespace("MAPI")
Set olMailItemObject = olApp.CreateItem(olMailItem)
Set SafeMailItem = CreateObject("Redemption.SafeMailItem")

SafeMailItem.Item = olMailItemObject
olMailItemObject.Body = "It would be nice it this one worked"
olMailItemObject.Subject = "Please!"
olMailItemObject.Recipients.Add ("Daniel Lamarche")
SafeMailItem.Recipients.ResolveAll
SafeMailItem.Send < It works better if I use
olMailItemObject.Sent

Set olMailItemObject = Nothing
Set SafeMailItem = Nothing
Set olApp = Nothing
Set ns = Nothing

End Sub

Any suggestion please? Thanks
Daniel Lamarche
 
S

Sue Mosher [MVP-Outlook]

The main problem is that you're changing properties of oMailItemObject
*after* you set the SafeMailItem.Item. That means the SafeMailItem knows
nothing about those changed properties. Instead, work with the properties
and methods of SafeMailItem.
 
D

Daniel Lamarche

So Sue, what would it look like then cause I'm not sure what your
explanation means!!

Thanks,

Daniel Lamarche
 
S

Sue Mosher [MVP-Outlook]

You have this:

The ResolveAll on the SafeMailItem doesn't resolve, because SafeMailItem has
no Recipients. You added the recipient instead to olMailItemObject. Once you
set SafeMailItem.Item, don't touch olMailItemObject again until you've saved
or sent the item.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

Daniel Lamarche

OK Sue. I think I did what you suggested me. Hope you wont start to hate me
because I don't understand. Usualy I understand pretty quickly though.
This will still not work. I used SafeMailItem all the way down I stiff
cannot see the recipient in the To box.

I noted in the Object Browser that there is a Resolve method for a Recipient
object. Would that be better?
Sorry to ask again.

Public Sub SendMailAgain()
Dim olApp As Outlook.Application
Dim olMailItemObject As Outlook.MailItem
Dim olNs As Outlook.NameSpace
Dim SafeMailItem As Redemption.SafeMailItem

Set olApp = CreateObject("Outlook.application")
Set olNs = olApp.GetNamespace("MAPI")
Set olMailItemObject = olApp.CreateItem(olMailItem)
Set SafeMailItem = CreateObject("Redemption.SafeMailItem")

SafeMailItem.Item = olMailItemObject
SafeMailItem.Body = "It would be nice it this one worked"
SafeMailItem.Subject = "Please!"
SafeMailItem.Recipients.Add ("Daniel Lamarche")
SafeMailItem.Recipients.ResolveAll
SafeMailItem.Display

Set olMailItemObject = Nothing
Set SafeMailItem = Nothing
Set olApp = Nothing
Set olNs = Nothing

End Sub
 
D

Dmitry Streblechenko \(MVP\)

1. Make sure you log to MAPI. After the line
Set ns = olApp.GetNamespace("MAPI")
add
ns.Logon

2. Try to display the duplicate name resolution dialog to make sure the
recipient gets resolved:
set Recip = olMailItemObject.Recipients.Add ("Daniel Lamarche")
Recip.Resolve(TRUE)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top