Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Microsoft Exchange Web服务-带有附件的邮件不';收不到收件人_C#_Asp.net Mvc - Fatal编程技术网

C# Microsoft Exchange Web服务-带有附件的邮件不';收不到收件人

C# Microsoft Exchange Web服务-带有附件的邮件不';收不到收件人,c#,asp.net-mvc,C#,Asp.net Mvc,我对Microsoft Exchange Web服务有问题。我尝试通过邮件发送表单信息。这很好用。 如果我添加了附件,邮件将无法送达收件人。没有任何错误消息或类似的东西 (我将Webservice作为nuget包集成到asp.net核心(模型视图控制器)项目中。) 有人能帮我吗 致意 JuRi-2020 public void sendMail(string bodyMessage, ComplainData complaint, string language, string path){

我对Microsoft Exchange Web服务有问题。我尝试通过邮件发送表单信息。这很好用。 如果我添加了附件,邮件将无法送达收件人。没有任何错误消息或类似的东西

(我将Webservice作为nuget包集成到asp.net核心(模型视图控制器)项目中。)

有人能帮我吗

致意

JuRi-2020

 public void sendMail(string bodyMessage, ComplainData complaint, string language, string path){ 
        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
        service.UseDefaultCredentials = true;
        service.Url = new Uri("sample");
        EmailMessage message = new EmailMessage(service);

        switch (language)
        {
            case "de":
                message.Subject = $"Reklamation von {complaint.CompanyName} wurde übermittelt.";
                message.Body = bodyMessage;
                message.Body.BodyType = BodyType.HTML;
                message.ToRecipients.Add("mail");
                if (path != null)
                {
                    message.Attachments.AddFileAttachment(path);
                }

                try
                {
                    message.Send();
                }
                catch
                {
                    this.successful = false;
                }
                break;}          }