'C# - Mail confirmation Outlook
I am developing an app that checks an Outlook mail account, finds all the attachments and then print them out. At this point, the mails analyzed are moved to another folder.
I have only one problem: sometimes, I receive some mails with reading confirmation. The app checks the attachment, and when it has to move the mail, it freezes. Then a popup appear in Outlook, about sending or not sending the reading confirmation.
Now, I want to make this programmatically, I always want to send a reading confirmation when it is requested.
I found a property (ReadReceiptRequested), set to true if there is a reading confirmation to send, but I don't know how to send it.
Here a piece of the code I use:
//I store all the emails in a List<Outlook.MailItem> named emails
Outlook.Application myApp = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
//Check if the mail has read confirmation
if (emails[right_index].ReadReceiptRequested)
{
//How to send read confirmation?
}
//I read the mail, then I move it to another folder
emails[indice_scelto].UnRead = false;
emails[indice_scelto].Move(mapiNameSpace.Folders["New folder"]);
Could you help me?
Thanks in advance!
Solution 1:[1]
You can do that on the Extended MAPI level (C++ or Delphi) - call IMessage::SetReadFlag() - pass 0 to send read receipts or SUPPRESS_RECEIPT otherwise.
If Redemption is an option (I am its author), it exposes the RDOMail.MarkRead method that takes a SuppressReceipt Boolean parameter.
Solution 2:[2]
The Outlook object model doesn't provide any property or method. All you can is to set the UnRead property to false and Save the item.
Then you can begin synchronizing a user's folders using the specified Send\Receive group using the Start method of the SyncObject class. The Namespace class provides the SyncObjects property which returns a SyncObjects collection containing all Send\Receive groups. For example:
Public Sub Sync()
Dim nsp As Outlook.NameSpace
Dim sycs As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
Dim i As Integer
Dim strPrompt As Integer
Set nsp = Application.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For i = 1 To sycs.Count
Set syc = sycs.Item(i)
strPrompt = MsgBox( _
"Do you wish to synchronize " & syc.Name &"?", vbYesNo)
If strPrompt = vbYes Then
syc.Start
End If
Next
End Sub
I suppose then you can move the item wherever you need.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Eugene Astafiev |
