Are you using a Redemption RDOSession object or what? You don't show enough
of your code to tell.
Generally if the user has started Outlook and you piggy-back on that session
you're all logged in. If Outlook is started using automation you either have
to log onto an RDOSession or if you're deriving things from NameSpace you
need to logon to the NameSpace before anything else and then make sure you
assign the NameSpace.MAPIOBJECT to the Redemption object's MAPIOBJECT.

Signature
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
> Hi,
>
[quoted text clipped - 25 lines]
>
> Jan
jpfi - 29 Jun 2006 15:52 GMT
Hi,
thanks Ken. I think my logon works correctly, because I can read the
mail-properties of mails sent by smtp-mailaccounts. But I cannot read
some mail-properties of mails sent by an exchange-account, e.g.
addressEntry.Type ist null.
It seems to me, that something around the addressbook doesn't work.
A little bit in detail:
I configure a scheduled task with username and password and my exe.
This user has a configured outlook-profile.
some code snippets:
//main-method opens outlook-App
Application outLookApp = new Application();
/* ...
* find correct MAPIFolder...
* get items of MAPIFolder...
* for each item get recipients an extract smtp-address--> call
extractTo(mailItem.Recipients)
* for each item get Sender an extract smtp-address--> call
extractMailAddress(mailItem.Sender)
*/
private StringCollection extractTo(SafeRecipients recipients){
System.Collections.IEnumerator enumerator =
recipients.GetEnumerator();
StringCollection list = new StringCollection();
while(enumerator.MoveNext()){
SafeRecipient recipient = (SafeRecipient)enumerator.Current;
if(OlMailRecipientType.olTo.GetHashCode() == recipient.Type)
list.Add(extractMailAddress(recipient.AddressEntry));
}
return list;
}
private String extractMailAddress(Redemption.AddressEntry
addressEntry){
String temp;
if(addressEntry.Type!=null && addressEntry.Type.Equals("EX")){
//39FE = PR_SMTP_ADDRESS 001E for type PT_String8
temp = (String)addressEntry.get_Fields(0x39FE001E);
if(temp == null){
//403E = PR_OrgEmailAddr 001E for type PT_String8
temp = (String)addressEntry.get_Fields(0x403E001E);
if(temp==null){
throw new
Exceptions.MailAddressCouldNotExtractedException(addressEntry.Address);
}
}
}
else{
temp = addressEntry.Address;
}
log.Debug("Address found: "+temp);
return temp;
}
jpfi
Ken Slovak - [MVP - Outlook] schrieb:
> Are you using a Redemption RDOSession object or what? You don't show enough
> of your code to tell.
[quoted text clipped - 42 lines]
> >
> > Jan
jpfi - 29 Jun 2006 17:18 GMT
Hi,
I tried the same thing with RDO as workaround.
SMTPAddress of RDOAdressEntry works correctly, also within a scheduled
task.
jpfi
Note that the scheduler runs as a service, and no Office app should be used
in a service.
Most likely Redemption cannot automatically pick up the MAPI session used by
Outlook, you can help it by calling something like the following first :
set Utils = CreateObject("Redemption.MAPIUtils")
Utils.MAPIOBJECT = YourOutlookApp.Session.MAPIOBJECT
'your old Redemption code goes here.
Thiswill ensure that Redemption caches teh MAPI session used by Outlook.
Or use the RDO family of objects...
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> Hi,
>
[quoted text clipped - 25 lines]
>
> Jan
jpfi - 30 Jun 2006 09:36 GMT
Hi,
I've tried setting the MAPIOBJECT, but it doesn't work.
but
Application outLookApp = new Application();
Redemption.RDOSession session =
(Redemption.RDOSession)outLookApp.CreateObject("Redemption.RDOSession");
session.MAPIOBJECT = outLookApp.Session.MAPIOBJECT;
RDOAddressEntry entry =
session.GetAddressEntryFromID(addressEntry.ID,null);
String smtp = entry.SMTPAddress;
works in all cases.
I still don't figure out why using the other code...
@Dimitry: Thanks for your great Utilities. My company just purchased a
license! Well done.
cheers, jan
Dmitry Streblechenko schrieb:
> Note that the scheduler runs as a service, and no Office app should be used
> in a service.
[quoted text clipped - 42 lines]
> >
> > Jan