Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now