C# ComAddIn: Imitate "Drag & Drop"

O

Ole Jaekel

Hello everyone!

I would like to imitate Outlooks Drag & Drop functionality on this case:
When you drag and drop an email message into the body of a Outlook Task Item
you normally receive a clickable link (named like the emails subject), which,
when clicked, opens the dropped email.

I would like to create such a link/reference using a ComAddIn. So far I
tried and succeeded to add an email to a task item as an attachment. the
email also appears in the body of the task item but is not clickable to open
the email.

my source code looks like this:
Code:
using MOIO = Microsoft.Office.Interop.Outlook;
....
//get the task item
MOIO.NameSpace olNS = ((MOIO.Application)applicationObject).GetNamespace
("MAPI");
MOIO.TaskItem iTaskItem = (MOIO.TaskItem) olNS.GetItemFromID(itemEntryID,
itemStoreID);
//get the mail item (same subject)
MOIO.MailItem iMailItem = null;
MOIO.MAPIFolder oMailFolder = getFolder("Posteingang");
MOIO.Items oItems = oMailFolder.Items;
foreach (MOIO.MailItem mail in oItems){
if (mail.MessageClass == "IPM.Note" &&
mail.Subject.Equals(iTaskItem.Subject.ToString())) {
iMailItem = mail;
}
}
//add mail as attachment to task item
iTaskItem.Attachments.Add(iMailItem, MOIO.OlAttachmentType.olByReference,
iTaskItem.Body.Length+1, iMailItem.Subject);
....

Can I use the method Attachments.Add to achieve this? do i have to alter the
parameters?

in the link you can see the result.
left attachment is added manually, right attachment is added
programmatically by my addin
http://web.inf.tu-dresden.de/~oj853436/studio/iTaskItem.Attachment.Add.GIF

I'd appreciate any suggestions!

Ciao Ole Jaekel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top