Пример #1
0
 /// <remarks/>
 public void CreateItemAsync(CreateItemType CreateItem1, object userState)
 {
     if ((this.CreateItemOperationCompleted == null))
     {
         this.CreateItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateItemOperationCompleted);
     }
     this.InvokeAsync("CreateItem", new object[] {
             CreateItem1}, this.CreateItemOperationCompleted, userState);
 }
Пример #2
0
 /// <remarks/>
 public System.IAsyncResult BeginCreateItem(CreateItemType CreateItem1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("CreateItem", new object[] {
             CreateItem1}, callback, asyncState);
 }
Пример #3
0
 /// <remarks/>
 public void CreateItemAsync(CreateItemType CreateItem1)
 {
     this.CreateItemAsync(CreateItem1, null);
 }
Пример #4
0
        /// <summary>
        /// Saves the given message to the drafts folder.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public ItemIdType SaveMessage(ChannelMessage message)
        {
            var binding = ChannelHelper.BuildChannel(hostname, username, password);

            var createItemRequest = new CreateItemType();

            // Indicate that we want to save only at first
            createItemRequest.MessageDisposition = MessageDispositionType.SaveOnly;
            createItemRequest.MessageDispositionSpecified = true;
            createItemRequest.Items = new NonEmptyArrayOfAllItemsType();

            // Create a single e-mail message.
            var exchMessage = new MessageType();
            exchMessage.Subject = message.Context;
            exchMessage.Body = new BodyType { BodyType1 = BodyTypeType.HTML, Value = message.BodyHtml.ReadString() };
            exchMessage.ItemClass = "IPM.Note";
            exchMessage.Sender = new SingleRecipientType();
            exchMessage.Sender.Item = new EmailAddressType { EmailAddress = message.From.Address };

            exchMessage.ToRecipients = new EmailAddressType[message.To.Count];
            exchMessage.CcRecipients = new EmailAddressType[message.CC.Count];
            exchMessage.BccRecipients = new EmailAddressType[message.BCC.Count];

            for (int i = 0; i < message.To.Count; i++)
                exchMessage.ToRecipients[i] = new EmailAddressType { EmailAddress = message.To[i].Address };

            for (int i = 0; i < message.CC.Count; i++)
                exchMessage.CcRecipients[i] = new EmailAddressType { EmailAddress = message.CC[i].Address };

            for (int i = 0; i < message.BCC.Count; i++)
                exchMessage.BccRecipients[i] = new EmailAddressType { EmailAddress = message.BCC[i].Address };

            exchMessage.Sensitivity = SensitivityChoicesType.Normal;

            // Add the message to the array of items to be created.
            createItemRequest.Items.Items = new ItemType[1];
            createItemRequest.Items.Items[0] = exchMessage;

            // Send the request to create and send the e-mail item, and get the response.
            CreateItemResponseType createItemResponse = binding.CreateItem(createItemRequest);

            // Determine whether the request was a success.
            if (createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
                throw new Exception(createItemResponse.ResponseMessages.Items[0].MessageText);

            return ((ItemInfoResponseMessageType)createItemResponse.ResponseMessages.Items[0]).Items.Items[0].ItemId;
        }