Quantcast
Channel: Aspose.Email Product Family
Viewing all articles
Browse latest Browse all 1367

Connecting to Exchange Server

$
0
0
Hi Aspose,

First of all, I would like to say I am newbe for email. What I would like to achieve is to download the attachment from email . I am reading documentation and testing with sample codes.
I try the following and got attached file error. Which part is wrong ???Am I in correct direction?? If not please guide me..
 We are using Outlook exchange 2007.


  [WebMethod]
        public string ConnectToExchangeServer(string ExchangeServer,string UserName,String Password)
        {
            string lstMessages = "";
            try
            {
          
                // Create instance of ExchangeClient class by giving credentials
                Aspose.Email.Exchange.ExchangeClient ExchangeClient = new Aspose.Email.Exchange.ExchangeClient(ExchangeServer,UserName,Password);

                // Get exchange mailbox info
                Aspose.Email.Exchange.ExchangeMailboxInfo mailboxInfo = ExchangeClient.GetMailboxInfo();

                // Get Mailbox URI
                Console.WriteLine("Mailbox URI: " + mailboxInfo.MailboxUri);

                // Call ListMessages method to list messages info from Inbox
                Aspose.Email.Exchange.ExchangeMessageInfoCollection msgCollection = ExchangeClient.ListMessages(ExchangeClient.MailboxInfo.InboxUri);

                // loop through the collection to display the basic information
                foreach (Aspose.Email.Exchange.ExchangeMessageInfo msgInfo in msgCollection)
                {
                    string strMsgInfo = "Subject: " + msgInfo.Subject +
                        " == From: " + msgInfo.From.ToString() +
                        " == To: " + msgInfo.To.ToString();
                    lstMessages+=strMsgInfo+"*************";
                }
                return lstMessages;
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

Thanks for your support


Viewing all articles
Browse latest Browse all 1367

Trending Articles