Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Redemption Question - showaddressbook and saveas (http://www.outlookbanter.com/outlook-vba/51960-redemption-question-showaddressbook-saveas.html)

[email protected] July 6th 07 09:55 AM

Redemption Question - showaddressbook and saveas
 
I know this is a VBA group and this is a powerbuilder question BUT I
noticed that the author of the Redemption code answers post here so I
thought I would try and post my question here

I have a PB application where I would like to show the address book
and let the users select the email addresses for the message being
sent.

I have the following code and this works as long as the user selects
the OK button from the address book dialog. Then everything works
like a charm BUT if the user selects Cancel from the address book
dialog you get a PB error message

Error calling external object function showaddressbook

I am using the newest version of Redemption and I am using the
RDOSession because I need to use the SaveAs function to save the
created email as a .msg file and found using the SaveMailitem that
this did not work. It would only save an empty email .msg file
unless
I used oleSafeMailItem.Item.SaveAs(filename,3) AND then you get the
dreaded Outlook Security message popup.


Session = Create OLEObject
li_Return = Session .ConnectToNewObject( "Redemption.RDOSession" )
Session .Logon
Msg = Session .GetDefaultFolder(4).Items.Add(0)
Msg.Recipients.Add " )
Msg.Recipients.ResolveAll
Msg.Subject = "Hello"
Msg.Body = "Testing Applications"
ab = Session .AddressBook


recips = AB.ShowAddressBook(Msg.Recipients) /* This is the line that
the error message is for BUT this does actually show the addressbook
but if the user clicks cancel this line then reports the error and
dies. I have debugged it and it is dying on this line.

Msg.Recipients = Recips


Any help would be greatly appreciated.


Thanks


Ken Slovak - [MVP - Outlook] July 6th 07 02:23 PM

Redemption Question - showaddressbook and saveas
 
Test to see if the returned collection from AddressBook is null or Nothing
or whatever PB uses to denote an empty collection. Only assign the returned
collection if it's not empty.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message
oups.com...
I know this is a VBA group and this is a powerbuilder question BUT I
noticed that the author of the Redemption code answers post here so I
thought I would try and post my question here

I have a PB application where I would like to show the address book
and let the users select the email addresses for the message being
sent.

I have the following code and this works as long as the user selects
the OK button from the address book dialog. Then everything works
like a charm BUT if the user selects Cancel from the address book
dialog you get a PB error message

Error calling external object function showaddressbook

I am using the newest version of Redemption and I am using the
RDOSession because I need to use the SaveAs function to save the
created email as a .msg file and found using the SaveMailitem that
this did not work. It would only save an empty email .msg file
unless
I used oleSafeMailItem.Item.SaveAs(filename,3) AND then you get the
dreaded Outlook Security message popup.


Session = Create OLEObject
li_Return = Session .ConnectToNewObject( "Redemption.RDOSession" )
Session .Logon
Msg = Session .GetDefaultFolder(4).Items.Add(0)
Msg.Recipients.Add " )
Msg.Recipients.ResolveAll
Msg.Subject = "Hello"
Msg.Body = "Testing Applications"
ab = Session .AddressBook


recips = AB.ShowAddressBook(Msg.Recipients) /* This is the line that
the error message is for BUT this does actually show the addressbook
but if the user clicks cancel this line then reports the error and
dies. I have debugged it and it is dying on this line.

Msg.Recipients = Recips


Any help would be greatly appreciated.


Thanks



Dmitry Streblechenko July 6th 07 10:13 PM

Redemption Question - showaddressbook and saveas
 
RDOAddressBook.ShowAddressBook simply raises a COM error if MAPI returns
anything but S_OK. When the address book dialog, is cancelled, the error is
MAPI_E_USER_CANCEL (0x80040113). This is normal, your code should expect and
handle that error.

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

wrote in message
oups.com...
I know this is a VBA group and this is a powerbuilder question BUT I
noticed that the author of the Redemption code answers post here so I
thought I would try and post my question here

I have a PB application where I would like to show the address book
and let the users select the email addresses for the message being
sent.

I have the following code and this works as long as the user selects
the OK button from the address book dialog. Then everything works
like a charm BUT if the user selects Cancel from the address book
dialog you get a PB error message

Error calling external object function showaddressbook

I am using the newest version of Redemption and I am using the
RDOSession because I need to use the SaveAs function to save the
created email as a .msg file and found using the SaveMailitem that
this did not work. It would only save an empty email .msg file
unless
I used oleSafeMailItem.Item.SaveAs(filename,3) AND then you get the
dreaded Outlook Security message popup.


Session = Create OLEObject
li_Return = Session .ConnectToNewObject( "Redemption.RDOSession" )
Session .Logon
Msg = Session .GetDefaultFolder(4).Items.Add(0)
Msg.Recipients.Add " )
Msg.Recipients.ResolveAll
Msg.Subject = "Hello"
Msg.Body = "Testing Applications"
ab = Session .AddressBook


recips = AB.ShowAddressBook(Msg.Recipients) /* This is the line that
the error message is for BUT this does actually show the addressbook
but if the user clicks cancel this line then reports the error and
dies. I have debugged it and it is dying on this line.

Msg.Recipients = Recips


Any help would be greatly appreciated.


Thanks




[email protected] July 7th 07 12:33 PM

Redemption Question - showaddressbook and saveas
 
On Jul 6, 9:23 am, "Ken Slovak - [MVP - Outlook]"
wrote:
Test to see if the returned collection from AddressBook is null or Nothing
or whatever PB uses to denote an empty collection. Only assign the returned
collection if it's not empty.

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm

wrote in message

oups.com...



I know this is a VBA group and this is a powerbuilder question BUT I
noticed that the author of the Redemption code answers post here so I
thought I would try and post my question here


I have a PB application where I would like to show the address book
and let the users select the email addresses for the message being
sent.


I have the following code and this works as long as the user selects
the OK button from the address book dialog. Then everything works
like a charm BUT if the user selects Cancel from the address book
dialog you get a PB error message


Error calling external object function showaddressbook


I am using the newest version of Redemption and I am using the
RDOSession because I need to use the SaveAs function to save the
created email as a .msg file and found using the SaveMailitem that
this did not work. It would only save an empty email .msg file
unless
I used oleSafeMailItem.Item.SaveAs(filename,3) AND then you get the
dreaded Outlook Security message popup.


Session = Create OLEObject
li_Return = Session .ConnectToNewObject( "Redemption.RDOSession" )
Session .Logon
Msg = Session .GetDefaultFolder(4).Items.Add(0)
Msg.Recipients.Add " )
Msg.Recipients.ResolveAll
Msg.Subject = "Hello"
Msg.Body = "Testing Applications"
ab = Session .AddressBook


recips = AB.ShowAddressBook(Msg.Recipients) /* This is the line that
the error message is for BUT this does actually show the addressbook
but if the user clicks cancel this line then reports the error and
dies. I have debugged it and it is dying on this line.


Msg.Recipients = Recips


Any help would be greatly appreciated.


Thanks- Hide quoted text -


- Show quoted text -


I alrad thought of that and tried a IsValid(recips) ... but it does
not actually get past the line that calls recips =
AB.ShowAddressBook ... so I don't even get a chance


[email protected] July 7th 07 12:36 PM

Redemption Question - showaddressbook and saveas
 
On Jul 6, 5:13 pm, "Dmitry Streblechenko" wrote:
RDOAddressBook.ShowAddressBook simply raises a COM error if MAPI returns
anything but S_OK. When the address book dialog, is cancelled, the error is
MAPI_E_USER_CANCEL (0x80040113). This is normal, your code should expect and
handle that error.

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

wrote in message

oups.com...



I know this is a VBA group and this is a powerbuilder question BUT I
noticed that the author of the Redemption code answers post here so I
thought I would try and post my question here


I have a PB application where I would like to show the address book
and let the users select the email addresses for the message being
sent.


I have the following code and this works as long as the user selects
the OK button from the address book dialog. Then everything works
like a charm BUT if the user selects Cancel from the address book
dialog you get a PB error message


Error calling external object function showaddressbook


I am using the newest version of Redemption and I am using the
RDOSession because I need to use the SaveAs function to save the
created email as a .msg file and found using the SaveMailitem that
this did not work. It would only save an empty email .msg file
unless
I used oleSafeMailItem.Item.SaveAs(filename,3) AND then you get the
dreaded Outlook Security message popup.


Session = Create OLEObject
li_Return = Session .ConnectToNewObject( "Redemption.RDOSession" )
Session .Logon
Msg = Session .GetDefaultFolder(4).Items.Add(0)
Msg.Recipients.Add " )
Msg.Recipients.ResolveAll
Msg.Subject = "Hello"
Msg.Body = "Testing Applications"
ab = Session .AddressBook


recips = AB.ShowAddressBook(Msg.Recipients) /* This is the line that
the error message is for BUT this does actually show the addressbook
but if the user clicks cancel this line then reports the error and
dies. I have debugged it and it is dying on this line.


Msg.Recipients = Recips


Any help would be greatly appreciated.


Thanks- Hide quoted text -


- Show quoted text -


Unfortunately it is not my code causing the error but something
internal to PB ... so maybe I am s**t out of luck!

Do you have any ideas about the savemailitem.SaveAs issue ... why does
this save a blank email msg but when I call savemailitem.item.saveas
it saves the email msg but then I get the security warning?

Thanks


Dmitry Streblechenko July 7th 07 10:30 PM

Redemption Question - showaddressbook and saveas
 
Can PB handle COM exception (that is how COM returns errors)?
In VB/VBA you can use "on error resume next" and then check the value of
err.Number. In other languages try/finally/except/catch blocks are used.
As for SaveAs, this is an indication that the item hasn't been saved, so
MAPI (and hence Redemption) cannot see the latest changes. Call
MailItem.Save first.

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

wrote in message
oups.com...
On Jul 6, 5:13 pm, "Dmitry Streblechenko" wrote:
RDOAddressBook.ShowAddressBook simply raises a COM error if MAPI returns
anything but S_OK. When the address book dialog, is cancelled, the error
is
MAPI_E_USER_CANCEL (0x80040113). This is normal, your code should expect
and
handle that error.

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

wrote in message

oups.com...



I know this is a VBA group and this is a powerbuilder question BUT I
noticed that the author of the Redemption code answers post here so I
thought I would try and post my question here


I have a PB application where I would like to show the address book
and let the users select the email addresses for the message being
sent.


I have the following code and this works as long as the user selects
the OK button from the address book dialog. Then everything works
like a charm BUT if the user selects Cancel from the address book
dialog you get a PB error message


Error calling external object function showaddressbook


I am using the newest version of Redemption and I am using the
RDOSession because I need to use the SaveAs function to save the
created email as a .msg file and found using the SaveMailitem that
this did not work. It would only save an empty email .msg file
unless
I used oleSafeMailItem.Item.SaveAs(filename,3) AND then you get the
dreaded Outlook Security message popup.


Session = Create OLEObject
li_Return = Session .ConnectToNewObject( "Redemption.RDOSession" )
Session .Logon
Msg = Session .GetDefaultFolder(4).Items.Add(0)
Msg.Recipients.Add " )
Msg.Recipients.ResolveAll
Msg.Subject = "Hello"
Msg.Body = "Testing Applications"
ab = Session .AddressBook


recips = AB.ShowAddressBook(Msg.Recipients) /* This is the line that
the error message is for BUT this does actually show the addressbook
but if the user clicks cancel this line then reports the error and
dies. I have debugged it and it is dying on this line.


Msg.Recipients = Recips


Any help would be greatly appreciated.


Thanks- Hide quoted text -


- Show quoted text -


Unfortunately it is not my code causing the error but something
internal to PB ... so maybe I am s**t out of luck!

Do you have any ideas about the savemailitem.SaveAs issue ... why does
this save a blank email msg but when I call savemailitem.item.saveas
it saves the email msg but then I get the security warning?

Thanks





All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com