Jump to content

Redemption AddressBook.ResolveName


Recommended Posts

I've searched the forums but couldn't find anything useful on this. Basically, I want to resolve the name(s) entered into a GUI using Redemption, and if they aren't found, the Outlook "Check Names" dialog pops up so the user can select the correct user.

At the moment, I can't seem to figure out how to get the result of the AddressBook.ResolveName to return the corrected name to my script.

$Application = ObjCreate("Outlook.Application")
$Session = objCreate("Redemption.RDOSession")
$Session.MAPIOBJECT = $Application.Session.MAPIOBJECT
$AdrrEntry = $Session.AddressBook.ResolveName("nicholas",true)

MsgBox(0,"",$AddrEntry.Address)

It's $AddrEntry.Address causing me pain - it's returning:

redemption_ab.au3(6,31) : WARNING: $AddrEntry: possibly used before declaration.
MsgBox(0,"",$AddrEntry.Address)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
redemption_ab.au3(6,31) : ERROR: $AddrEntry: undeclared global variable.
MsgBox(0,"",$AddrEntry.Address)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
redemption_ab.au3 - 1 error(s), 1 warning(s)

Any hints would be greatly appreciated!

cheers,

Spud

Link to comment
Share on other sites

I think you'll find that $AddrEntry is not an object (use an IsObj test).

best suggestion I think would be to get your code working in VBScript first (the outlook and redemption object code) and then work on converting the working vbs into AutoIt. This will take one big variable out of the picture.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

G'day DaleHolm,

Thanks for the quick reply.

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set AdrrEntry = Session.AddressBook.ResolveName("dmitry")
MsgBox "The address of the name is " & AddrEntry.Address

That's the code straight from http://www.dimastr.com/redemption/rdo/rdoaddressbook.htm . I'm an idiot for not testing it before converting to autoit - it's broken in VBS too. I'll do some more research and see how I go.

Link to comment
Share on other sites

Funny. That was hard to see.

I'm working with the Redemption library right now too, so I'd be interested to see anything you get working. I'm trying to convert display names into SMTP addresses and hitting snags.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

By the looks of things you're a far far more advanced coder than I am, but here's what I've got now...

$Application = ObjCreate("Outlook.Application")
$Session = objCreate("Redemption.RDOSession")
$Session.MAPIOBJECT = $Application.Session.MAPIOBJECT
$Drafts = $Session.GetDefaultFolder(16)
$Msg = $Drafts.Items.Add
$Msg.To = $RecipientX
$Msg.Recipients.ResolveAll(true)
$Msg.Subject = $Subject
$Msg.HTMLBody = $Message
$Msg.Importance = $UrgentX
$Msg.Send

$RecipientX can be either one or more names, seperated by a semi-colon. It works perfectly unless you cancel the Check Names dialog for a name that couldn't be resolved - it basically just ends the script and leaves the message in the drafts folder. I can't figure out how to capture the fact that the user cancelled the dialog.

I wouldn't even bother with using RDO/Outlook except I need a record of the sent message in the users' Sent Items. I'll keep on trying...!

Link to comment
Share on other sites

Are you able to get this redemption example to work for you? I get no value returned.

dim utils, MailItem, PrSenderEmailAddress, SenderEMail
Set Outlook = CreateObject("Outlook.Application")
set utils = CreateObject("Redemption.MAPIUtils")
set MailItem = Outlook.Session.GetDefaultFolder(6).Items(1)  'Get the first item in the inbox, can be any other item
PrSMTPAddress= &H39FE001E
'PrSMTPAddress= &H800F101E ' Use for exchange cache mode??
SenderEMail = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSMTPAddress)
MsgBox SenderEMail

In my translation to au3 I get a Type Mismatch (the IE stuff is just to easily get the COM error handler).

I'm trying to narrow down whether it is an issue with OL2007, exchange cache mode or something else.

#include <IE.au3>
_IEErrorHandlerRegister()

$Outlook = ObjCreate("Outlook.Application")
$utils = ObjCreate("Redemption.MAPIUtils")
$MailItem = $Outlook.Session.GetDefaultFolder(6).Items(1)  ;Get the first item in the inbox, can be any other mail item
;$PrSMTPAddress= 0x39FE001E
$PrSMTPAddress= 0x800F101E ; for exchange cache mode??
;Get SMTP address of the first recipient. It is assumed that the recipient is an Exchange Server user.
$SMTPAddress = $utils.HrGetOneProp($MailItem.Recipients(1).AddressEntry.MAPIOBJECT, $PrSMTPAddress)
MsgBox (0, "", $SMTPAddress)

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

When I run the VBS I'm not getting a value returned for SenderEmail either.

I'm running OL2003 in Exchange but cache mode disabled.

The AU3 attempts to get the address from OL (I'm getting the security prompt) but it's returning:

redemption_ab_dale.au3 (7) : ==> The requested action with this object has failed.: 
$SMTPAddress = $utils.HrGetOneProp($MailItem.Recipients(1).AddressEntry.MAPIOBJECT, $PrSMTPAddress) 
$SMTPAddress = $utils.HrGetOneProp($MailItem.Recipients(1).AddressEntry.MAPIOBJECT^ ERROR

Edit: Maybe try using SafeMail instead of MAPIProp?

Edited by SpuddyMcSpud
Link to comment
Share on other sites

Actually, give this VBS a crack. Works for me.

set Application = CreateObject("Outlook.Application")
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set oContact = Application.Session.GetDefaultFolder(10).Items(10)
set Contact = CreateObject("Redemption.SafeContactItem")
Contact.Item = oContact 'never use "Set" when setting the Item property
MsgBox Contact.Email1Address

I changed line 4 to GetDefaultFolder(10).Items(10) since .Items(1) in my contacts list appears to be empty.

Link to comment
Share on other sites

Thanks, I appreciate the example.

It works, although it returns "", X.400 info or SMTP depending on the contact entry... I'm not wanting to work out of my contact list however. Ideally, what I want to do is to enter a bunch of names in Ex formal (e,g, Smith, John;Doe, Jane) or domain\username and get SMTP email entries back.

More study to do...

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...