A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

use of Redemption in sceduled Task



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 29th 06, 11:37 AM posted to microsoft.public.outlook.program_vba
jpfi
external usenet poster
 
Posts: 4
Default use of Redemption in sceduled Task

Hi,

I've written an console-application based on Redemption
(http://www.dimastr.com/redemption/)).
the following code tries to resolve the smtp-Address of the mailsender:

if(addressEntry.Type.Equals("EX")){
//39FE = PR_SMTP_ADDRESS 001E for type PT_String8
String 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(a ddressEntry.Address);
}
}
return temp;
}

In case of starting the application in normal way the shown code works.
addressEntry.get_Fields(0x39FE001E) return the correct value.
When handling the same mail by starting the app per sceduled task (same
user performer) addressEntry.get_Fields(0x39FE001E) return null !

any idea?
Thank you,

Jan

Ads
  #2  
Old June 29th 06, 02:52 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default use of Redemption in sceduled Task

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.

--
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


"jpfi" wrote in message
ups.com...
Hi,

I've written an console-application based on Redemption
(http://www.dimastr.com/redemption/)).
the following code tries to resolve the smtp-Address of the mailsender:

if(addressEntry.Type.Equals("EX")){
//39FE = PR_SMTP_ADDRESS 001E for type PT_String8
String 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(a ddressEntry.Address);
}
}
return temp;
}

In case of starting the application in normal way the shown code works.
addressEntry.get_Fields(0x39FE001E) return the correct value.
When handling the same mail by starting the app per sceduled task (same
user performer) addressEntry.get_Fields(0x39FE001E) return null !

any idea?
Thank you,

Jan


  #3  
Old June 29th 06, 03:52 PM posted to microsoft.public.outlook.program_vba
jpfi
external usenet poster
 
Posts: 4
Default use of Redemption in sceduled Task

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(a ddressEntry.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.

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.

--
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


"jpfi" wrote in message
ups.com...
Hi,

I've written an console-application based on Redemption
(http://www.dimastr.com/redemption/)).
the following code tries to resolve the smtp-Address of the mailsender:

if(addressEntry.Type.Equals("EX")){
//39FE = PR_SMTP_ADDRESS 001E for type PT_String8
String 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(a ddressEntry.Address);
}
}
return temp;
}

In case of starting the application in normal way the shown code works.
addressEntry.get_Fields(0x39FE001E) return the correct value.
When handling the same mail by starting the app per sceduled task (same
user performer) addressEntry.get_Fields(0x39FE001E) return null !

any idea?
Thank you,

Jan


  #4  
Old June 29th 06, 05:18 PM posted to microsoft.public.outlook.program_vba
jpfi
external usenet poster
 
Posts: 4
Default use of Redemption in sceduled Task

Hi,

I tried the same thing with RDO as workaround.
SMTPAddress of RDOAdressEntry works correctly, also within a scheduled
task.

jpfi

  #5  
Old June 29th 06, 05:49 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default use of Redemption in sceduled Task

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

"jpfi" wrote in message
ups.com...
Hi,

I've written an console-application based on Redemption
(http://www.dimastr.com/redemption/)).
the following code tries to resolve the smtp-Address of the mailsender:

if(addressEntry.Type.Equals("EX")){
//39FE = PR_SMTP_ADDRESS 001E for type PT_String8
String 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(a ddressEntry.Address);
}
}
return temp;
}

In case of starting the application in normal way the shown code works.
addressEntry.get_Fields(0x39FE001E) return the correct value.
When handling the same mail by starting the app per sceduled task (same
user performer) addressEntry.get_Fields(0x39FE001E) return null !

any idea?
Thank you,

Jan



  #6  
Old June 30th 06, 09:36 AM posted to microsoft.public.outlook.program_vba
jpfi
external usenet poster
 
Posts: 4
Default use of Redemption in sceduled Task

Hi,
I've tried setting the MAPIOBJECT, but it doesn't work.
but

Application outLookApp = new Application();
Redemption.RDOSession session =
(Redemption.RDOSession)outLookApp.CreateObject("Re demption.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.
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

"jpfi" wrote in message
ups.com...
Hi,

I've written an console-application based on Redemption
(http://www.dimastr.com/redemption/)).
the following code tries to resolve the smtp-Address of the mailsender:

if(addressEntry.Type.Equals("EX")){
//39FE = PR_SMTP_ADDRESS 001E for type PT_String8
String 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(a ddressEntry.Address);
}
}
return temp;
}

In case of starting the application in normal way the shown code works.
addressEntry.get_Fields(0x39FE001E) return the correct value.
When handling the same mail by starting the app per sceduled task (same
user performer) addressEntry.get_Fields(0x39FE001E) return null !

any idea?
Thank you,

Jan


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
inconsistent in Redemption Vadivel Outlook and VBA 10 April 25th 06 06:12 PM
show all recurrences of a task in the task list dash Outlook - Calandaring 2 April 15th 06 02:45 AM
How do I drag a task in task list of Outlook. It will not let me. rpetralia Outlook - Calandaring 2 April 5th 06 10:14 AM
Redemption Christoph Add-ins for Outlook 5 March 6th 06 03:26 PM
Redemption MAPITable Dmitry Streblechenko Add-ins for Outlook 1 January 12th 06 04:09 AM


All times are GMT +1. The time now is 03:52 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.