【问题标题】:How to connect other user outlook mail using my PC如何使用我的电脑连接其他用户的 Outlook 邮件
【发布时间】:2019-05-02 15:53:36
【问题描述】:

我想使用用户凭据从我的电脑读取/连接其他用户收件箱邮件(office Outlook 2010)。 但我遇到了错误。

找不到自动发现服务

请给我一个解决方案。

    public void ConnectToExchangeServer()
    {
        ExchangeService exchange = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
        try
        {
            exchange.TraceEnabled = true;
            exchange.Credentials = new WebCredentials("xyz", "xyz", "xyz.in");  
            exchange.AutodiscoverUrl("xyz@xyz.com", RedirectionUrlValidationCallback);
            exchange.Url `enter code here`= new Uri("https://usercomputername.domainname");

            EnableFolderPermissions(exchange);                
        }
        catch (Exception ex)
        {

        }
    }

【问题讨论】:

  • 您确定您的 exchange.Url 指向正确的 URL,即您的 EWS 托管 API 的地址吗? "The autodiscover field (in your exchange server settings) needs to be populated with an address that ends with: "EWS/Exchange.asmx"." 另见:support.practicepanther.com/calendar-and-events/troubleshooting/…stackoverflow.com/questions/15065363/…
  • 如果您(作为测试)使用邮箱所有者的凭据,自动发现是否有效?
  • 您好,基本上当我尝试在“exchange.AutodiscoverUrl”上进行调试时,会出现“找不到自动发现服务”错误。我正在使用邮箱所有者用户名、密码和域名。并且还使用 exchange.Url = new Uri("userCompName.userDomainName/EWS/Exchange.asmx")
  • 您是否在域网络之外尝试此操作?

标签: c# exchangewebservices office-interop outlook-2010


【解决方案1】:

如何使用'MailServer'特定收件箱文件夹中只读取未读邮件

这是我的代码:

        if (!Directory.Exists(mailbox))
        {
            Directory.CreateDirectory(mailbox);
        }
        MailServer oServer = new MailServer("servername",
                    "username", "password", ServerProtocol.Imap4);
        MailClient oClient = new MailClient("TryIt");
        oServer.SSLConnection = true;
        oServer.Port = 143;     
        try
        {
            oClient.Connect(oServer);
            MailInfo[] infos = oClient.GetMailInfos();
            for (int i = 0; i < infos.Length; i++)
            {
                MailInfo info = infos[i];
                Console.WriteLine("Index: {0}; Size: {1}; UIDL: {2}; Flags: {3}",
                    info.Index, info.Size, info.UIDL, info.Flags);

                // Receive email from POP3 server
                Mail oMail = oClient.GetMail(info);

                Console.WriteLine("From: {0}", oMail.From.ToString());
                Console.WriteLine("To: {0}", oMail.To.ToString());
                Console.WriteLine("Subject: {0}\r\n", oMail.Subject);
                if (oMail.Attachments.Length > 0)
                {
                    for (int j = 0; j <= oMail.Attachments.Length - 1; j++)
                        {
                            System.DateTime d = System.DateTime.Now;
                            System.Globalization.CultureInfo cur = new System.Globalization.CultureInfo("en-US");
                            string sdate = d.ToString("MMddyyyyHHmmss", cur);
                            string fileName = String.Format("{0}\\{1}{2}{3}.eml", mailbox, sdate, d.Millisecond.ToString("d3"), i);

                            // Save email to local disk
                            oMail.SaveAs(fileName, true);



                            // Mark email as deleted from POP3 server.
                            oClient.Delete(info);
                        }
                    }
            }
            // Quit and purge emails marked as deleted from POP3 server.
            oClient.Quit();
        }
        catch (Exception ep)
        {
            Console.WriteLine(ep.Message);
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-10
    • 1970-01-01
    • 2012-05-09
    • 2018-12-26
    • 1970-01-01
    相关资源
    最近更新 更多