Solved

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

Posted on 2009-05-12
4
662 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

777 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