Solved

How to obtain the "message-id" of the emails just sent out?

Posted on 2009-05-12
4
669 Views
Last Modified: 2013-12-17
I am working on an application, which sends out emails through Exchange server, and track and process the replies. In order to link the reply with the original outbound email, we need to know the "message-id" field of the emails sent out.

The email sending and receiving are done with WebDAV calls. Does someone know the answer?
0
Comment
Question by:nbkd72e
  • 2
4 Comments
 
LVL 15

Expert Comment

by:abhaigh
ID: 24372766
the field you are wanting to capture is the 'Message-ID:' field

it will look like this in the smtp headers

Message-ID: <DD3A01CC964AA34B80CCB895A38B0241DC4F02@mx.domain.com>
0
 

Author Comment

by:nbkd72e
ID: 24374925
How to obtain the SMTP headers? Our applications access Exchange server through OWA and WebDAV.
0
 
LVL 15

Accepted Solution

by:
abhaigh earned 500 total points
ID: 24375955
I found this - perhaps it will help you

Re: Find CDO Message.ID with WebDAV
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.messaging/2004-07/0151.html

Now I found the problem myself, here is the solution:

String query = "<?xml version=\"1.0\"?>"
+ "<g:searchrequest xmlns:g=\"DAV:\">"
+ "<g:sql>SELECT
\"http://schemas.microsoft.com/mapi/proptag/0x0FFF0102\"
AS entryId "
+ "FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUri
+ "\"') "
+ "WHERE \"DAV:contentclass\" = 'urn:content-
classes:task' "
//+ additional wheres
//send the query, parse results ...

byte[] bytes = Convert.FromBase64String( entryId );
String taskID = String.Empty;
String currentNumber;
foreach(byte b in bytes){
        currentNumber = b.ToString("X");
        if(currentNumber.Length == 1){
                currentNumber = "0"+currentNumber;
        }
        taskID += currentNumber;
}

session.Logon(defaultProfileName, "", false, false,
Missing.Value, Missing.Value, Missing.Value);
MAPI.Folder taskFolder = (MAPI.Folder)
session.GetDefaultFolder(8);

MAPI.Message message = (MAPI.Message)session.GetMessage
(taskIDs[1], infoStoreID);
Console.WriteLine(message.Subject.ToString());

session.Logon(defaultProfileName, "", false, false,
Missing.Value, Missing.Value, Missing.Value);
MAPI.Folder taskFolder = (MAPI.Folder)
session.GetDefaultFolder(8);

MAPI.Message message = (MAPI.Message)session.GetMessage
(taskIDs[1], infoStoreID);
Console.WriteLine(message.Subject.ToString());
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question