예제 #1
0
        public static void SendRemoteWipeConfirmationMessage(string[] addresses, ExDateTime wipeAckTime, MailboxSession mailboxSession, DeviceIdentity deviceIdentity, object traceObject)
        {
            bool        flag            = false;
            MessageItem messageItem     = null;
            CultureInfo preferedCulture = mailboxSession.PreferedCulture;

            try
            {
                StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts);
                messageItem           = MessageItem.Create(mailboxSession, defaultFolderId);
                messageItem.ClassName = "IPM.Note.Exchange.ActiveSync.RemoteWipeConfirmation";
                messageItem.Subject   = Strings.RemoteWipeConfirmationMessageSubject.ToString(preferedCulture);
                string format = (addresses == null) ? Strings.RemoteWipeConfirmationMessageBody1Owa.ToString(preferedCulture) : Strings.RemoteWipeConfirmationMessageBody1Task.ToString(preferedCulture);
                string text   = AirSyncUtility.HtmlEncode(string.Format(CultureInfo.InvariantCulture, format, new object[]
                {
                    wipeAckTime
                }), false);
                string text2 = AirSyncUtility.HtmlEncode(string.Format(CultureInfo.InvariantCulture, Strings.DeviceType.ToString(preferedCulture), new object[]
                {
                    deviceIdentity.DeviceType
                }), false);
                string text3 = AirSyncUtility.HtmlEncode(string.Format(CultureInfo.InvariantCulture, Strings.DeviceId.ToString(preferedCulture), new object[]
                {
                    deviceIdentity.DeviceId
                }), false);
                using (TextWriter textWriter = messageItem.Body.OpenTextWriter(BodyFormat.TextHtml))
                {
                    textWriter.Write("\r\n            <html>\r\n                <style>\r\n                    {0}\r\n                </style>\r\n                <body>\r\n                    <h1>{1}</h1>\r\n                    <br><br>\r\n                    <p>\r\n                        {2}\r\n                        <br><br>\r\n                        {3}\r\n                        <br>\r\n                        {4}\r\n                        <br><br>\r\n                        <font color=\"red\">\r\n                        {5}\r\n                        </font>\r\n                        <br><br>\r\n                        {6}\r\n                        <br><br>\r\n                    </p>\r\n                </body>\r\n            </html>\r\n            ", new object[]
                    {
                        "\r\n            body\r\n            {\r\n                font-family: Tahoma;\r\n                background-color: rgb(255,255,255);\r\n                color: #000000;\r\n                font-size:x-small;\r\n                width: 600px\r\n            }\r\n            p\r\n            {\r\n                margin:0in;\r\n            }\r\n            h1\r\n            {\r\n                font-family: Arial;\r\n                color: #000066;\r\n                margin: 0in;\r\n                font-size: medium; font-weight:bold\r\n            }\r\n            ",
                        AirSyncUtility.HtmlEncode(Strings.RemoteWipeConfirmationMessageHeader.ToString(preferedCulture), false),
                        text,
                        text2,
                        text3,
                        AirSyncUtility.HtmlEncode(Strings.RemoteWipeConfirmationMessageBody2.ToString(preferedCulture), false),
                        AirSyncUtility.HtmlEncode(Strings.RemoteWipeConfirmationMessageBody3.ToString(preferedCulture), false)
                    });
                }
                messageItem.From = null;
                Participant participant = new Participant(mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), "SMTP");
                messageItem.Recipients.Add(participant, RecipientItemType.To);
                if (addresses != null)
                {
                    foreach (string emailAddress in addresses)
                    {
                        Participant participant2 = new Participant(null, emailAddress, "SMTP");
                        messageItem.Recipients.Add(participant2, RecipientItemType.Bcc);
                    }
                }
                messageItem.Send();
                flag = true;
            }
            finally
            {
                if (messageItem != null)
                {
                    if (!flag)
                    {
                        ProvisionCommand.DeleteMessage(messageItem, mailboxSession, traceObject);
                    }
                    messageItem.Dispose();
                }
            }
        }
예제 #2
0
 void IProvisionCommandHost.SendRemoteWipeConfirmationMessage(ExDateTime wipeAckTime)
 {
     ProvisionCommand.SendRemoteWipeConfirmationMessage(base.GlobalInfo.RemoteWipeConfirmationAddresses, wipeAckTime, base.MailboxSession, base.Context.Request.DeviceIdentity, this);
 }