![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |