C# Outlook的发布控制

C# Outlook的发布控制,c#,outlook,office-interop,C#,Outlook,Office Interop,我有一个使用Office Interop的应用程序,它启动outlook,创建电子邮件并向其中附加文件。我的问题是,在发送/关闭电子邮件之前,程序不会继续处理。我如何发布它,所以一旦运行下面的代码,在最终用户修改电子邮件时,其余代码将继续?是像在不同的线程中运行代码那样简单,还是有更好的方法 if (!Common.IsOutlookRunning()) Process.Start("OUTLOOK.EXE"); var outlook = new Ou

我有一个使用Office Interop的应用程序,它启动outlook,创建电子邮件并向其中附加文件。我的问题是,在发送/关闭电子邮件之前,程序不会继续处理。我如何发布它,所以一旦运行下面的代码,在最终用户修改电子邮件时,其余代码将继续?是像在不同的线程中运行代码那样简单,还是有更好的方法

 if (!Common.IsOutlookRunning())
            Process.Start("OUTLOOK.EXE");
        var outlook = new Outlook.Application();
        var message = (Outlook.MailItem)outlook.CreateItem(Outlook.OlItemType.olMailItem);
        message.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
        var recipients = (Outlook.Recipients)message.Recipients;
        var recipient = (Outlook.Recipient)recipients.Add(hire.Email);
        message.HTMLBody = "<p style=\"font-size:9.0pt;font-family:Verdana,sans-serif;color:#000066\">" +
        "Dear " + hire.ClientName + ",<br><br>";
        message.HTMLBody += "Please see the attached document. If you have any queries, please feel free to give me a call or send me an email.";
        var position = (int)message.HTMLBody.Length + 1;
        const int attachType = (int)Outlook.OlAttachmentType.olByValue;
        const string attachmentName = "Hire Docket";
        message.Attachments.Add(path, attachType, position, attachmentName);
        message.Subject = hire.Quote ? "Hire Quote" : "Hire Docket";
        message.BCC = "email@email.com";
        message.HTMLBody += "</p>" + Common.ReadSignature();
        recipient.Resolve();
        message.Display(true);
if(!Common.IsOutlookRunning())
Process.Start(“OUTLOOK.EXE”);
var outlook=new outlook.Application();
var message=(Outlook.MailItem)Outlook.CreateItem(Outlook.OlItemType.olMailItem);
message.BodyFormat=Outlook.OlBodyFormat.olFormatHTML;
var recipients=(Outlook.recipients)message.recipients;
var recipient=(Outlook.recipient)recipients.Add(hire.Email);
message.HTMLBody=“

”+ “亲爱的”+hire.ClientName+“,

”; message.HTMLBody+=“请参阅附件。如果您有任何疑问,请随时给我打电话或发送电子邮件。”; 变量位置=(int)message.HTMLBody.Length+1; const int attachType=(int)Outlook.OlAttachmentType.olByValue; const string attachmentName=“雇佣摘要”; 添加(路径、附件类型、位置、附件名称); message.Subject=hire.Quote?“雇佣报价”:“雇佣摘要”; message.BCC=”email@email.com"; message.HTMLBody+=“

”+Common.ReadSignature(); recipient.Resolve(); message.Display(true);
为了解决这个问题,我让它在另一个线程中运行,并让主线程做其他事情

var thread = new Thread(() => Method(Parameters));
thread.Start();