示例#1
0
 protected static void CreateAndSubmitMessage(MapiFolder folder, string sourceMailboxName, string targetMailAddress, string subject, bool deleteAfterSubmit)
 {
     using (MapiMessage mapiMessage = folder.CreateMessage())
     {
         PropValue[] props = new PropValue[]
         {
             new PropValue(PropTag.DeleteAfterSubmit, deleteAfterSubmit),
             new PropValue(PropTag.Subject, subject),
             new PropValue(PropTag.ReceivedByEmailAddress, targetMailAddress),
             new PropValue(PropTag.Body, "This is a Test-Mailflow probe message.")
         };
         mapiMessage.SetProps(props);
         mapiMessage.ModifyRecipients(ModifyRecipientsFlags.AddRecipients, new AdrEntry[]
         {
             new AdrEntry(new PropValue[]
             {
                 new PropValue(PropTag.EmailAddress, targetMailAddress),
                 new PropValue(PropTag.OriginatorDeliveryReportRequested, deleteAfterSubmit),
                 new PropValue(PropTag.AddrType, "SMTP"),
                 new PropValue(PropTag.RecipientType, RecipientType.To),
                 new PropValue(PropTag.DisplayName, sourceMailboxName)
             })
         });
         mapiMessage.SaveChanges();
         mapiMessage.SubmitMessage(SubmitMessageFlags.ForceSubmit);
     }
 }