B
bjornte
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.OlItemType.olMailItem);
safeItem.Item = mailItem;
safeItem.Recipients.Add("(e-mail address removed)");
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.olFolderInbox).StoreID;
Outlook.MailItem mailItem =
(Outlook.MailItem)olNS.GetItemFromID(entryID, storeID);
Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
safeItem.Item = mailItem;
safeItem.Recipients.Add("(e-mail address removed)");
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
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.OlItemType.olMailItem);
safeItem.Item = mailItem;
safeItem.Recipients.Add("(e-mail address removed)");
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.olFolderInbox).StoreID;
Outlook.MailItem mailItem =
(Outlook.MailItem)olNS.GetItemFromID(entryID, storeID);
Interop.Redemption.SafeMailItem safeItem = new
SafeMailItem();
safeItem.Item = mailItem;
safeItem.Recipients.Add("(e-mail address removed)");
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