【问题标题】:How to open Outlook 2016 with vs2017如何使用 vs2017 打开 Outlook 2016
【发布时间】:2018-03-10 04:38:13
【问题描述】:

我的电脑上有 Office 2013 32 位。我开发了一个 Intranet,但在我客户的服务器和 Windows 会话上:它是 Office 2016 32 位... 在我的 vs2017 上,我安装了块包 microsoft.office.interop 15.0.4797.1003 但它适用于 Office 2013。 我用

创建邮件
dim outl as new outlook.application
dim Mai las outl.mailitem=outl.createItem(Micrososft.office.Interop.outlook.olitemtype.olmailItem)
Mail.To=...
...
Mail.attachment.add(MyFile)
Mail.display()

我尝试将我的代码放在客户服务器上,就像我认为的那样...... 80070005 访问被拒绝...... 我找不到如何打开 Outlook 2016 感谢您的帮助

更新 在我的项目的属性上,我激活了“任何 CPU”选项

【问题讨论】:

  • 哪一行引发了异常? Outlook 是否正在运行?是否有任何一个应用程序(包括 VS)以提升的权限运行(以管理员身份运行)?
  • 抱歉迟到了。我尝试在具有高权限的帐户(不是管理员,但关闭)上关闭 Outlook,并且我需要我的代码为所有人运行。它是任何人都可以访问的报价生成器。
  • 那么哪一行引发了异常?
  • 我不知道。导致我的计算机上没有编译问题。只是在服务器上尝试。我尝试将一些跟踪记录到文件中以跟踪错误。
  • 您需要重新考虑在服务器上启动 Outlook 的想法:Considerations for server-side Automation of Office。您应该使用System.Net.Mail Namespace 中的方法来创建电子邮件。

标签: vb.net outlook


【解决方案1】:

终于... 一个朋友说我,我的方法只有在服务器上打开会话才能正常。 outlook.display 在服务器上运行,而不是在其他计算机的客户端上运行。 然后我改变主意,建一个 emml 文件,用 ashx 文件存储和推送

 For Each _file As String In IO.Directory.GetFiles(IO.Path.GetDirectoryName(Path), "*.eml")
                        IO.File.Delete(_file)
                    Next

                    Dim MailMdp As New Net.Mail.MailMessage
                    MailMdp.Subject = Vers.Devi.Libelle
                    MailMdp.From = New Net.Mail.MailAddress(ConnectedUser.Mail)

                        MailMdp.To.Add(AnAdress)

                    MailMdp.Body = "Bonjour,"
                    Dim att As New Net.Mail.Attachment(Path)
                    MailMdp.Attachments.Add(att)
                    MailMdp.IsBodyHtml = True

                    Dim Client As Net.Mail.SmtpClient = New Net.Mail.SmtpClient()
                    Client.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory
                    Client.PickupDirectoryLocation = IO.Path.GetDirectoryName(Path)
                    Client.Send(MailMdp)

                    Dim MonEml = IO.Directory.GetFiles(IO.Path.GetDirectoryName(Path), "*.eml", IO.SearchOption.TopDirectoryOnly).First

                    Dim fso As New System.IO.FileInfo(MonEml)
                    Dim NomFichier As String = fso.Name
                    context.Response.Clear()
                    context.Response.ClearContent()
                    context.Response.ClearHeaders()
                    context.Response.ContentType = "message/rfc822"
                    context.Response.AppendHeader("Content-Disposition", "attachment; filename=" & NomFichier)
                    context.Response.TransmitFile(MonEml)
                    context.Response.End()

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 2018-11-28
    • 1970-01-01
    • 2020-10-30
    • 2018-04-10
    • 1970-01-01
    相关资源
    最近更新 更多