Managed API - new messages appear unsent RRS feed

  • Question

  • Managed API 1.1 @ Exchange_2010SP1 @ VS2010SP1 C#

    I'm doing an import task from a groupware solution with emails stored in a database into Exchange 2010SP1. The source table includes email xml definitions sent times, from, to, cc and bcc information. The excact nature of the source data is not important to this question though.

    When I create a message in a mailbox with these arbitrary email addresses the newly created emails they appear in outlook as if they had not been sent, ie as draft messages. My method for creating and saving the messages follows (roughly).


    EmailMessage emailMessage = new EmailMessage(Service);
    emailMessage.FromEddaDocument(Service, doc.DocumentAsciiData);
    emailMessage.Subject += " #KT(" + doc.CustomerNr.Fusc() + ")";
    emailMessage = EmailMessage.Bind(Service, emailMessage.Id);
    // The static method for reference
            public static void FromEddaDocument(this EmailMessage msg, ExchangeService service, string xml)
                var doc = new XmlDocument();
                var node = GetSingleNode(doc, "/EMAIL/FROM/ADDRESS/EMAIL_ADDRESS");
                msg.From = new EmailAddress(GetSmtpAddress(node.InnerText, service));
                    msg.From.Address = "noreply@vis.is";
                msg.Sender = msg.From;
                foreach (var rec in GetNonEmptyNodes(doc, "/EMAIL/TO/ADDRESS/EMAIL_ADDRESS"))
                    msg.ToRecipients.Add(GetSmtpAddress(rec.InnerText, service));
                foreach (var rec in GetNonEmptyNodes(doc, "/EMAIL/CC/ADDRESS/EMAIL_ADDRESS"))
                    msg.CcRecipients.Add(GetSmtpAddress(rec.InnerText, service));
                foreach (var rec in GetNonEmptyNodes(doc, "/EMAIL/BCC/ADDRESS/EMAIL_ADDRESS"))
                    msg.BccRecipients.Add(GetSmtpAddress(rec.InnerText, service));
                // msg.IsSubmitted = 
                //  PR_CLIENT_SUBMIT_TIME
                var sentDate = DateTime.Parse(GetSingleNode(doc, "/EMAIL/SENT").InnerText);
                msg.SetExtendedProperty(new ExtendedPropertyDefinition(57, MapiPropertyType.SystemTime), sentDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                // PR_MESSAGE_DELIVERY_TIME 
                msg.SetExtendedProperty(new ExtendedPropertyDefinition(3590, MapiPropertyType.SystemTime), sentDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
                msg.Subject = GetSingleNode(doc, "/EMAIL/SUBJECT").InnerText;
                msg.Body = string.Join(Environment.NewLine,
                                       from n in GetNodes(doc, "/EMAIL/BODY_PARTS/BODY_PART/TEXT") select n.InnerText);
                foreach (var attNode in GetNodes(doc, "/EMAIL/ATTACHMENTS/ATTACHMENT"))
                    var filename = attNode.SelectSingleNode("FILENAME").InnerText;
                    var base64 = attNode.SelectSingleNode("DATA").InnerText;
                    msg.Attachments.AddFileAttachment(filename, Convert.FromBase64String(base64));
                msg.IsRead = true;


    Can I mark the messages as read using some extended property (like I'm doing with the sent date)? I've read through the list at http://msdn.microsoft.com/en-us/library/cc815517.aspx but can't spot one that suits my needs.


    Regards, Högni

    • Edited by Hogni Friday, December 9, 2011 10:50 AM
    Friday, December 9, 2011 9:35 AM

All replies