如何在Outlook 32bit或64位自动打印HTML附件

发布于 2025-01-23 12:30:21 字数 329 浏览 2 评论 0原文

当客户从网站下订单时,将带有附件文件(HTML格式)的电子邮件发送给管理层以获取其订单,我们希望通过Outlook自动打印它,我在整个上进行了搜索互联网,但我找不到适合这份工作的脚本。

谁能创建VBA Scriptor Outlook 2016 32bit Outlook 2019 64bit ,当新电子邮件包含附件时,可以直接保存和打印?

我尝试了很多脚本,但是它们没有帮助我,也无法自动打印HTML文件,我进行了所有必要的设置,但是该脚本不起作用。

When a customer places an order from the site, an email with an attached file (HTML format) is sent to the management for his order and we want to print it automatically through Outlook, I searched all over the internet but the script I did not find a suitable one for this job.

Can anyone create a VBA Scriptfor Outlook 2016 32bit or Outlook 2019 64bit that can be saved and printed directly when a new email contains an attachment?

I tried many scripts but they did not help me and could not print the HTML file automatically, I made all the necessary settings but the script does not work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久而酒知 2025-01-30 12:30:21

要处理VBA中传入的电子邮件,您可以处理 Outlook应用程序类的事件。 newMailex事件发生在收件箱中和客户端规则处理之前时发射。此事件将对Microsoft Outlook处理的每个收到的项目发射一次。该项目可以是几种不同的项目类型之一,例如,mailItemefferitem ,或sharingItementryIdScollection字符串包含与该项目相对应的输入ID。使用entryCollection数组中返回的输入ID,以调用 namespace.getItemfromid 方法和处理项目。

检索项目后,您可以检查 tacterments.count.count.count.count.count.count 财产并决定是否打印它。

要打印传入电子邮件项目的内容,您可以使用 MailItem.printout 使用所有默认设置打印Outlook项目的方法。 打印输出方法是唯一可以用于打印的Outlook方法。

但是要打印所附的HTML文件,您需要先将其保存在磁盘上,然后将其调用print动词,例如:

Sub PrintFile(FileToPrint as string)
    Dim objShell
    Set objShell = CreateObject("Shell.Application")

        If FileToPrint = "" Then
            GoTo MainLoop
        Else
            Debug.Print FileToPrint
            
            objShell.Namespace(0).ParseName(FileToPrint).InvokeVerb ("Print")
          
        End If
MainLoop:
     Debug.Print "No files to print"
End Sub

To handle incoming emails in VBA you can handle the NewMailEx event of the Outlook Application class. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item. Use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.

After an item is retrieved you could check the Attachments.Count property and decide whether to print it or not.

To print the content of the incoming email item you can use the MailItem.PrintOut method which prints the Outlook item using all default settings. The PrintOut method is the only Outlook method that can be used for printing.

But to print the attached HTML file you need to save it on the disk first and then call the print verb against the saved file, for example:

Sub PrintFile(FileToPrint as string)
    Dim objShell
    Set objShell = CreateObject("Shell.Application")

        If FileToPrint = "" Then
            GoTo MainLoop
        Else
            Debug.Print FileToPrint
            
            objShell.Namespace(0).ParseName(FileToPrint).InvokeVerb ("Print")
          
        End If
MainLoop:
     Debug.Print "No files to print"
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文