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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Adding recipients to existing mail Items using Redemption



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 27th 07, 11:02 AM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 1
Default Adding recipients to existing mail Items using Redemption

Hi,
I have a situation where I want to modify an existing item in Outlook,
but I cant get the recipients to work properly when using Redemption.

First I create a new mail item, add some properties (like subject,
recipients etc), get hold of the EntryID and exit.
Later on I reconnect and find the mailItem using GetItemFromID and
start modifying this Item.

Changing the Subject works just fine, but I cant seem to get the
Recipients modified correctly.
When I add a recipient it is apparently added, using OutlookSpy to
view the "CurrentItem.To" property I can see all my recipients.
However, the ones I added when I modified the Item is not visible in
Outlook and if I manually enter a new mailaddress (in Outlook), the
ones I added in the modification code disappears from the
"CurrentItem.To" property in OutlookSpy as well.

If I use Outlook directly (no Redemption code), I can get this
working, but I dont want the Security message box, so it is not really
an alternative.

I created a small sample program that demonstrates this problem:

using Outlook = Microsoft.Office.Interop.Outlook;
using Interop.Redemption;

private void main()
{
string entryID = RedemptionCreateTestMail();
RedemptionAddRecipient(entryID);
}

private string RedemptionCreateTestMail()
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
Outlook.MailItem mailItem =
(Outlook.MailItem)olApp.CreateItem(Outlook.OlItemT ype.olMailItem);
safeItem.Item = mailItem;

");
safeItem.Recipients.ResolveAll();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

string entryID = mailItem.EntryID;

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;

return entryID;
}

private void RedemptionAddRecipient(string entryID)
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

string storeID =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderInbox).StoreID;
Outlook.MailItem mailItem =
(Outlook.MailItem)olNS.GetItemFromID(entryID, storeID);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
safeItem.Item = mailItem;
");
safeItem.Recipients.ResolveAll();

mailItem.Subject = "Attached to mail: " + entryID;

mailItem.Save();
mailItem.Display(false);

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;
}

Bjorn Tore

Ads
  #2  
Old April 27th 07, 07:35 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Adding recipients to existing mail Items using Redemption

Outlook cannot see any changes made with Extended MAPI until you completely
dereference and reopen the item.
For some reason Outlook refereshes it internal cache of recipients when you
add a user property (you can immediately delete) it after you add a
recipient but before you display it.

");
safeItem.Recipients.ResolveAll();
prop = mailItem.UserProperties.Add( "test", 1 );
prop.Value = "test";
prop.Delete();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

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

wrote in message
oups.com...
Hi,
I have a situation where I want to modify an existing item in Outlook,
but I cant get the recipients to work properly when using Redemption.

First I create a new mail item, add some properties (like subject,
recipients etc), get hold of the EntryID and exit.
Later on I reconnect and find the mailItem using GetItemFromID and
start modifying this Item.

Changing the Subject works just fine, but I cant seem to get the
Recipients modified correctly.
When I add a recipient it is apparently added, using OutlookSpy to
view the "CurrentItem.To" property I can see all my recipients.
However, the ones I added when I modified the Item is not visible in
Outlook and if I manually enter a new mailaddress (in Outlook), the
ones I added in the modification code disappears from the
"CurrentItem.To" property in OutlookSpy as well.

If I use Outlook directly (no Redemption code), I can get this
working, but I dont want the Security message box, so it is not really
an alternative.

I created a small sample program that demonstrates this problem:

using Outlook = Microsoft.Office.Interop.Outlook;
using Interop.Redemption;

private void main()
{
string entryID = RedemptionCreateTestMail();
RedemptionAddRecipient(entryID);
}

private string RedemptionCreateTestMail()
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
Outlook.MailItem mailItem =
(Outlook.MailItem)olApp.CreateItem(Outlook.OlItemT ype.olMailItem);
safeItem.Item = mailItem;

");
safeItem.Recipients.ResolveAll();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

string entryID = mailItem.EntryID;

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;

return entryID;
}

private void RedemptionAddRecipient(string entryID)
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

string storeID =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderInbox).StoreID;
Outlook.MailItem mailItem =
(Outlook.MailItem)olNS.GetItemFromID(entryID, storeID);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
safeItem.Item = mailItem;
");
safeItem.Recipients.ResolveAll();

mailItem.Subject = "Attached to mail: " + entryID;

mailItem.Save();
mailItem.Display(false);

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;
}

Bjorn Tore



  #3  
Old April 27th 07, 08:19 PM posted to microsoft.public.outlook.program_addins
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Adding recipients to existing mail Items using Redemption

Very useful. How on earth did you ever figure that out?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Dmitry Streblechenko" wrote in message ...
Outlook cannot see any changes made with Extended MAPI until you completely
dereference and reopen the item.
For some reason Outlook refereshes it internal cache of recipients when you
add a user property (you can immediately delete) it after you add a
recipient but before you display it.

");
safeItem.Recipients.ResolveAll();
prop = mailItem.UserProperties.Add( "test", 1 );
prop.Value = "test";
prop.Delete();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

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

wrote in message
oups.com...
Hi,
I have a situation where I want to modify an existing item in Outlook,
but I cant get the recipients to work properly when using Redemption.

First I create a new mail item, add some properties (like subject,
recipients etc), get hold of the EntryID and exit.
Later on I reconnect and find the mailItem using GetItemFromID and
start modifying this Item.

Changing the Subject works just fine, but I cant seem to get the
Recipients modified correctly.
When I add a recipient it is apparently added, using OutlookSpy to
view the "CurrentItem.To" property I can see all my recipients.
However, the ones I added when I modified the Item is not visible in
Outlook and if I manually enter a new mailaddress (in Outlook), the
ones I added in the modification code disappears from the
"CurrentItem.To" property in OutlookSpy as well.

If I use Outlook directly (no Redemption code), I can get this
working, but I dont want the Security message box, so it is not really
an alternative.

I created a small sample program that demonstrates this problem:

using Outlook = Microsoft.Office.Interop.Outlook;
using Interop.Redemption;

private void main()
{
string entryID = RedemptionCreateTestMail();
RedemptionAddRecipient(entryID);
}

private string RedemptionCreateTestMail()
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
Outlook.MailItem mailItem =
(Outlook.MailItem)olApp.CreateItem(Outlook.OlItemT ype.olMailItem);
safeItem.Item = mailItem;

");
safeItem.Recipients.ResolveAll();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

string entryID = mailItem.EntryID;

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;

return entryID;
}

private void RedemptionAddRecipient(string entryID)
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

string storeID =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderInbox).StoreID;
Outlook.MailItem mailItem =
(Outlook.MailItem)olNS.GetItemFromID(entryID, storeID);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
safeItem.Item = mailItem;
");
safeItem.Recipients.ResolveAll();

mailItem.Subject = "Attached to mail: " + entryID;

mailItem.Save();
mailItem.Display(false);

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;
}

Bjorn Tore



  #4  
Old April 27th 07, 09:07 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Adding recipients to existing mail Items using Redemption

The usual head scratching "why does this work in one place but not in
another?" :-)

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

"Sue Mosher [MVP-Outlook]" wrote in message
...
Very useful. How on earth did you ever figure that out?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Dmitry Streblechenko" wrote in message
...
Outlook cannot see any changes made with Extended MAPI until you
completely
dereference and reopen the item.
For some reason Outlook refereshes it internal cache of recipients when
you
add a user property (you can immediately delete) it after you add a
recipient but before you display it.

");
safeItem.Recipients.ResolveAll();
prop = mailItem.UserProperties.Add( "test", 1 );
prop.Value = "test";
prop.Delete();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

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

wrote in message
oups.com...
Hi,
I have a situation where I want to modify an existing item in Outlook,
but I cant get the recipients to work properly when using Redemption.

First I create a new mail item, add some properties (like subject,
recipients etc), get hold of the EntryID and exit.
Later on I reconnect and find the mailItem using GetItemFromID and
start modifying this Item.

Changing the Subject works just fine, but I cant seem to get the
Recipients modified correctly.
When I add a recipient it is apparently added, using OutlookSpy to
view the "CurrentItem.To" property I can see all my recipients.
However, the ones I added when I modified the Item is not visible in
Outlook and if I manually enter a new mailaddress (in Outlook), the
ones I added in the modification code disappears from the
"CurrentItem.To" property in OutlookSpy as well.

If I use Outlook directly (no Redemption code), I can get this
working, but I dont want the Security message box, so it is not really
an alternative.

I created a small sample program that demonstrates this problem:

using Outlook = Microsoft.Office.Interop.Outlook;
using Interop.Redemption;

private void main()
{
string entryID = RedemptionCreateTestMail();
RedemptionAddRecipient(entryID);
}

private string RedemptionCreateTestMail()
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
Outlook.MailItem mailItem =
(Outlook.MailItem)olApp.CreateItem(Outlook.OlItemT ype.olMailItem);
safeItem.Item = mailItem;

");
safeItem.Recipients.ResolveAll();
mailItem.Subject = "Mail Created";
mailItem.Save();
mailItem.Display(false);

string entryID = mailItem.EntryID;

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;

return entryID;
}

private void RedemptionAddRecipient(string entryID)
{
Outlook.Application olApp = new Outlook.Application();
Outlook.NameSpace olNS =
(Outlook.NameSpace)olApp.GetNamespace("MAPI");
olNS.Logon("", "", false, true);

string storeID =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderInbox).StoreID;
Outlook.MailItem mailItem =
(Outlook.MailItem)olNS.GetItemFromID(entryID, storeID);

Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
safeItem.Item = mailItem;
");
safeItem.Recipients.ResolveAll();

mailItem.Subject = "Attached to mail: " + entryID;

mailItem.Save();
mailItem.Display(false);

mailItem = null;
safeItem = null;
olNS.Logoff();
olNS = null;
olApp = null;
}

Bjorn Tore





 




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
Problem adding attendees to existing appointment Lars Add-ins for Outlook 1 October 17th 06 04:56 PM
Redemption: Recipients aren't added after CreateItemFromTemplate() [email protected] Add-ins for Outlook 4 September 4th 06 01:38 PM
Catastrophic Failure while accessing Redemption.SafeMailItem.To and Recipients jisha Outlook and VBA 1 June 30th 06 05:48 PM
Adding a Member (existing in GAL) to a Public Distribution List in K.N.Ganesh. Outlook and VBA 1 May 23rd 06 08:25 PM
Problem with Sent Items/Redemption קובץ Outlook and VBA 10 January 12th 06 03:26 PM


All times are GMT +1. The time now is 08:14 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-2025 Outlook Banter.
The comments are property of their posters.