Uniquely Identifies MailItem

Add-in Express™ Support Service
That's what is more important than anything else

Uniquely Identifies MailItem
 
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Rup,
you can use Extended MAPI to obtain the internet header from an email.

private void btnShowIH_Click(object sender)
{
object mapiObject = null;
Outlook._Explorer explorer = OutlookHost().ActiveExplorer();
if (explorer == null) return;
Outlook.Selection selObject = explorer.Selection;
if (selObject == null) return;
object item = selObject.Item(1);
if (item is Outlook._MailItem)
{
mapiObject = (item as Outlook._MailItem).MAPIOBJECT;
}
else if (item is Outlook._RemoteItem)
{
mapiObject = (item as Outlook._RemoteItem).MAPIOBJECT;
}
if (mapiObject != null)
{
string iheader = String.Empty;
IntPtr pPropValue = IntPtr.Zero;
IntPtr unk = IntPtr.Zero;
try
{
IntPtr unkObj = Marshal.GetIUnknownForObject(mapiObject);
Guid iMapiProp = new Guid("00020303-0000-0000-C000-000000000046");
Marshal.QueryInterface(unkObj, ref iMapiProp, out unk);
Marshal.Release(unkObj);
if (unk != IntPtr.Zero)
{
MAPI.HrGetOneProp(unk, MAPI.PR_TRANSPORT_MESSAGE_HEADERS, out pPropValue);
MAPI.SPropValue propValue = (MAPI.SPropValue)Marshal.PtrToStructure(pPropValue, typeof(MAPI.SPropValue));
iheader = Marshal.PtrToStringAnsi(new IntPtr(propValue.Value));
}
}
catch
{
}
if (pPropValue != IntPtr.Zero)
MAPI.MAPIFreeBuffer(pPropValue);
if (unk != IntPtr.Zero)
Marshal.Release(unk);
Marshal.ReleaseComObject(mapiObject);
if (iheader != String.Empty)
{
ContentForm ihForm = new ContentForm();
ihForm.Text = "Internet Header";
ihForm.HeaderText.AppendText(iheader);
switch(ihForm.ShowDialog())
{
case DialogResult.OK:
item.GetType().InvokeMember("Display", BindingFlags.InvokeMethod, null, item, new object[]{false});
break;
case DialogResult.Yes:
item.GetType().InvokeMember("Delete", BindingFlags.InvokeMethod, null, item, null);
break;
}
ihForm.Dispose();
}
}
if (item != null) Marshal.ReleaseComObject(item);
Marshal.ReleaseComObject(selObject);
Marshal.ReleaseComObject(explorer);
}
Posted 16 Apr, 2007 08:21:41 Top
Alex Abramov




Posts: 34
Joined: 2006-09-15
Rup,

I'm sorry, it wasn't a link... the http: namespace throws off... These are just different names of the property, depending on which api you use

PR_INTERNET_MESSAGE_ID,
urn:schemas:mailheader:message-id,
http://schemas.microsoft.com/mapi/proptag/0x1035001E

Alex
Posted 16 Apr, 2007 10:43:24 Top
Rup Go




Posts: 64
Joined: 2007-03-01
Hi Sergey,

is MAPI in the code a class u made? i cant find its namespace

thanks
Posted 16 Apr, 2007 22:08:35 Top
Rup Go




Posts: 64
Joined: 2007-03-01
Hi alex,

hmm im kinda new here and i dont knw how to use that.? can u elaborate or give an example. thank you very much
Posted 17 Apr, 2007 04:00:50 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Rup,
please download 'Add-in Express Toys .NET for Microsoft Outlook':
http://www.add-in-express.com/free-addins/net-outlook-addin.php
Posted 18 Apr, 2007 10:28:12 Top
Rup Go




Posts: 64
Joined: 2007-03-01
thanks Sergey!

add in express toys needs .net framework 1.1, i'm using vs2005 does this mean that the installer package that il be producing should have prereq .net framework 2 & 1?

thanks
Posted 18 Apr, 2007 23:08:02 Top
Rup Go




Posts: 64
Joined: 2007-03-01
hmm i got it, never mind my question ^_^
Posted 19 Apr, 2007 01:33:12 Top
Rup Go




Posts: 64
Joined: 2007-03-01
hi again Sergey,

i got the header of the mail item and it shows me a lot of watsoever stuff, subject, from, to and etc. so is there a way for me to insert something in it? like mydetail : xxx at the end.

dont know how to insert text here, the code just tell me how to retrieve hmm but how can i insert/save it?

much like the mail item object where i can .save() the object

thanks a lot!

i really appreciate all the reply
Posted 19 Apr, 2007 02:42:57 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Rup.

Please try to use CDO to add X-header to the outgoing message.
http://www.ivasoft.biz/addxheader.html


P.S. Note that we take up your forum requests in the order we receive them. Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 19 Apr, 2007 09:07:10 Top
Rup Go




Posts: 64
Joined: 2007-03-01
if i insert a text call XXX-keyname in the header file and save it then i replied to the mail, and my friend replied back will the inserted text in the header still be there? coz that is what im aiming for.

if you guys have ideas/suggestions on how to do it even if not inserting in the header i would like to hear from you. (inserting tracking text permanently)

thanks!

and btw, are their other way other than using the CDO it seems to me that it is not for commercial use. thanks.
Posted 19 Apr, 2007 22:41:04 Top