Проблема с полем Кому в Outlook 2016 - PullRequest
0 голосов
/ 21 ноября 2018

Я пытаюсь создать электронное письмо и сохранить его в папке черновиков пользователя, которая в настоящее время работает нормально.Однако электронная почта имеет гигантское поле «Кому» и не отправляется должным образом, когда пользователи отправляют электронную почту из папки черновиков.Есть идеи?Эта проблема, кажется, появляется только в Outlook 2016. В настоящее время это мой метод сохранения. enter image description here

public void Save(string saveToEmailAddress, string recipient, string subject, IEnumerable<MailAttachment> attachments)
        {
            try
            {
                // We need to impersonate the User whose account we are adding a Draft email to
                _exchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, saveToEmailAddress);

                var email = new EmailMessage(_exchangeService)
                {
                    Subject = subject
                };
                email.ToRecipients.Add(recipient);

                foreach (var attachment in attachments)
                {
                    email.Attachments.AddFileAttachment(attachment.FileName, attachment.Content);
                }
                email.Save();
            }
            finally
            {
                // Stop impersonating the User account
                // If this doesn't happen, any email sent from this Service
                // will appear to be coming from the Impersonated account (not the Intranet)
                _exchangeService.ImpersonatedUserId = null;
            }
        }

1 Ответ

0 голосов
/ 22 ноября 2018

Вы можете обратиться к приведенному ниже коду:

Microsoft.Office.Interop.Outlook.Application app;
                try
                {
                    app = (Microsoft.Office.Interop.Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
                }
                catch
                {
                    app = new Microsoft.Office.Interop.Outlook.Application();
                }

                if (app == null)
                {
                    return;
                }
                string stringHtmlBodyfromFile = File.ReadAllText(@"codeFileUrl");
                Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) as
                                                                     Microsoft.Office.Interop.Outlook.MailItem;
                mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
                mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
                mailItem.Subject = “subject”;
               mailItem.Recipients.Add("");
                mailItem.HTMLBody = stringHtmlBodyfromFile;
                mailItem.CC = cc;

                mailItem.Attachments.Add(@"AttachmentUrl");
                mailItem.Save();
                        }
            catch (Exception eX)
            {
               // XtraMessageBox.Show(eX.Message + "\n" + eX.StackTrace + "\n" + eX.Source + "\n" + eX.InnerException);
            }
...