메인 컨텐츠로 가기

전자 메일이 Outlook에 도착할 때 자동으로 첨부 파일을 인쇄하는 방법은 무엇입니까?

이 자습서에서는 VBA 스크립트와 Outlook 규칙을 결합하여 특정 이메일이 Outlook에 도착할 때 첨부 파일을 자동으로 인쇄하는 데 도움이 되는 방법을 보여줍니다.


특정 이메일이 도착하면 자동으로 첨부 파일 인쇄

특정 발신자로부터 수신되는 이메일의 첨부 파일을 자동으로 인쇄하려고 한다고 가정합니다. 다음과 같이 하면 완료할 수 있습니다.

1단계: Outlook에서 스크립트 만들기

먼저 Outlook에서 VBA 스크립트를 만들어야 합니다.

1. Outlook을 시작하고 다른 + F11 동시에 열려면 키 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창, 더블 클릭 Project1 > Microsoft Outlook 개체 > ThisOutlook세션 를 열려면 ThisOutlookSession (코드) 창을 열고 다음 코드를 이 코드 창에 복사합니다.

VBA 코드 1: 이메일이 도착하면 자동으로 첨부 파일(모든 유형의 첨부 파일) 인쇄

Sub AttachementAutoPrint(Item As Outlook.MailItem)
'Updated by Extendoffice 20230223
  Dim xFS As FileSystemObject
  Dim xTempFolder As String
  Dim xAtt As Attachment
  Dim xShell As Object
  Dim xFolder As Object, xFolderItem As Object
  Dim xFileName As String
  On Error GoTo xError
  If Item.Attachments.Count = 0 Then Exit Sub
  Set xFS = New FileSystemObject
  xTempFolder = xFS.GetSpecialFolder(TemporaryFolder)
  xTempFolder = xTempFolder & "\ATMP" & Format(Item.ReceivedTime, "yyyymmddhhmmss")
  If Not xFS.FolderExists(xTempFolder) Then
    MkDir (xTempFolder)
  End If
  Set xShell = CreateObject("Shell.Application")
  Set xFolder = xShell.NameSpace(0)
  For Each xAtt In Item.Attachments
    If IsEmbeddedAttachment(xAtt) = False Then
      xFileName = xTempFolder & "\" & xAtt.FileName
      xAtt.SaveAsFile (xFileName)
      Set xFolderItem = xFolder.ParseName(xFileName)
      xFolderItem.InvokeVerbEx ("print")
    End If
  Next xAtt
  Set xFS = Nothing
  Set xFolder = Nothing
  Set xFolderItem = Nothing
  Set xShell = Nothing
xError:
  If Err <> 0 Then
    MsgBox Err.Number & " - " & Err.Description, , "Kutools for Outlook"
    Err.Clear
  End If
Exit Sub
End Sub

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
    xHtml = xItem.HTMLBody
    xID = "cid:" & xCid
    If InStr(xHtml, xID) > 0 Then
        IsEmbeddedAttachment = True
    End If
End If
End Function

참고 : 이 코드는 이메일로 받은 모든 유형의 첨부 파일 인쇄를 지원합니다. pdf 파일과 같이 지정된 유형의 첨부 파일만 인쇄하려면 다음 VBA 코드를 적용하십시오.

VBA 코드 2: 이메일이 도착하면 지정된 유형의 첨부 파일을 자동으로 인쇄합니다.

Sub AttachementAutoPrint(Item As Outlook.MailItem)
'Updated by Extendoffice 20230223
  Dim xFS As FileSystemObject
  Dim xTempFolder As String
  Dim xAtt As Attachment
  Dim xShell As Object
  Dim xFolder As Object, xFolderItem As Object
  Dim xFileType As String, xFileName As String
  On Error GoTo xError
  If Item.Attachments.Count = 0 Then Exit Sub
  Set xFS = New FileSystemObject
  xTempFolder = xFS.GetSpecialFolder(TemporaryFolder)
  xTempFolder = xTempFolder & "\ATMP" & Format(Item.ReceivedTime, "yyyymmddhhmmss")
  If Not xFS.FolderExists(xTempFolder) Then
    MkDir (xTempFolder)
  End If
  Set xShell = CreateObject("Shell.Application")
  Set xFolder = xShell.NameSpace(0)
  For Each xAtt In Item.Attachments
    If IsEmbeddedAttachment(xAtt) = False Then
      xFileName = xAtt.FileName
      xFileType = LCase$(Right$(xFileName, VBA.Len(xFileName) - VBA.InStrRev(xFileName, ".")))
      xFileName = xTempFolder & "\" & xFileName
      Select Case xFileType
        Case "pdf"   'change "pdf" to the file extension you want to print
          xAtt.SaveAsFile (xFileName)
          Set xFolderItem = xFolder.ParseName(xFileName)
          xFolderItem.InvokeVerbEx ("print")
      End Select
    End If
  Next xAtt
  Set xFS = Nothing
  Set xFolder = Nothing
  Set xFolderItem = Nothing
  Set xShell = Nothing
xError:
  If Err <> 0 Then
    MsgBox Err.Number & " - " & Err.Description, , "Kutools for Outlook"
    Err.Clear
  End If
  Exit Sub
End Sub

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
    xHtml = xItem.HTMLBody
    xID = "cid:" & xCid
    If InStr(xHtml, xID) > 0 Then
        IsEmbeddedAttachment = True
    End If
End If
End Function

노트:

1. 이 VBA 코드를 적용하여 수신 이메일의 pdf 파일만 인쇄하기 전에 먼저 다운로드하여 설치해야 합니다. Adobe Acrobat Reader가 컴퓨터의 기본 PDF 리더로 설정합니다.
2. 라인에서 사례 "pdf", 바꿔주세요 "pdf" 인쇄하려는 파일 확장명으로

3. 계속해서 클릭 도구 > 참조. 팝업에서 참조 – 프로젝트1 대화 상자에서 Microsoft 스크립팅 런타임 상자를 클릭 한 다음 OK 버튼을 클릭합니다.

4. 코드를 저장하고 다른 + Q 닫는 키 응용 프로그램 용 Microsoft Visual Basic 창.

참고 : 다음 사항을 확인하십시오. 모든 매크로 사용 Outlook에서 옵션이 활성화되어 있습니다. 아래 표시된 단계에 따라 이 옵션을 확인할 수 있습니다.

2단계: 스크립트를 사용하는 규칙 작성

Outlook에서 VBA 스크립트를 추가한 후 특정 조건에 따라 스크립트를 사용하는 규칙을 만들어야 합니다.

1. 홈 탭으로 이동하여 규칙 > 규칙 및 경고 관리.

2. 에서 규칙 및 경고 대화 상자에서 새로운 규칙 버튼을 클릭하여 규칙을 만듭니다.

팁 : Outlook에 여러 이메일 계정을 추가한 경우에는 계정을 지정하십시오. 이 폴더에 변경 사항 적용 규칙을 적용할 드롭다운 목록입니다. 그렇지 않으면 현재 선택한 이메일 계정의 받은 편지함에 적용됩니다.

3. 첫 번째 규칙 마법사 대화 상자에서 수신 한 메일에 규칙 적용 FBI 증오 범죄 보고서 1단계 상자를 클릭 한 다음 다음.

4. 두 번째 규칙 마법사 대화 상자에서 다음을 수행해야합니다.

4.1) 에 하나 이상의 조건을 지정하십시오. 1단계 당신의 필요에 따라 상자;
이 경우 지정된 발신자로부터 수신되는 이메일의 첨부 파일만 인쇄하고 싶습니다. 여기서 나는 확인한다. 사람 또는 공개 그룹에서 상자.
4.2) 밑줄 친 값을 클릭하십시오. 2단계 조건을 편집하는 상자;
4.3) 클릭 다음. 스크린 샷을 참조하십시오 :

5. 세 번째 규칙 마법사 대화 상자에서 다음과 같이 구성해야합니다.

5.1)에서 1단계: 작업 섹션 선택, 을 체크하다 스크립트 실행 상자;
5.2)에서 2단계 섹션에서 밑줄이 그어진 텍스트 "스크립트"를 클릭하십시오.
5.3) 오프닝에서 스크립트 선택 대화 상자에서 위에서 추가한 VBA 코드의 이름을 클릭한 다음 승인;
5.4) 클릭 다음 보기 단추. 스크린 샷보기 :

팁 : "스크립트 실행" 옵션이 귀하의 규칙 마법사, 이 문서에서 언급한 방법에 따라 표시할 수 있습니다. Outlook 규칙에서 누락된 스크립트 실행 pption 복원.

6. 또 다른 규칙 마법사 예외를 묻는 팝업이 나타납니다. 필요한 경우 예외를 선택할 수 있습니다. 그렇지 않으면 다음 보기 선택 항목이 없는 버튼。

7. 마지막에 규칙 마법사, 규칙의 이름을 지정한 다음 마감재 버튼을 클릭합니다.

8. 그런 다음 규칙 및 경고 대화 상자에서 생성한 규칙이 내부에 나열되어 있는 것을 볼 수 있습니다. OK 버튼을 눌러 전체 설정을 마칩니다.

이제부터 지정된 사람의 이메일이 수신되면 첨부 파일이 자동으로 인쇄됩니다.


관련 기사

Outlook에서 하나의 이메일 또는 선택한 이메일의 첨부 파일만 인쇄
Outlook에서 이메일을 인쇄할 수 있지만 Outlook에서 하나의 이메일 또는 선택한 이메일의 첨부 파일만 인쇄했습니까? 이 문서에서는 이 작업을 해결하는 방법을 소개합니다.

Outlook에서 이메일의 메시지 헤더만 인쇄
Outlook에서 이메일을 인쇄할 때 이메일의 메시지 헤더와 메시지 본문을 모두 인쇄합니다. 그러나 어떤 특별한 경우에는 제목, 보낸 사람, 받는 사람 등의 메시지 헤더를 인쇄해야 할 수도 있습니다. 이 기사에서는 이를 수행하는 두 가지 솔루션을 소개합니다.

Outlook에서 지정된/사용자 지정 날짜 범위의 달력 인쇄
일반적으로 Outlook의 월별 보기에서 달력을 인쇄할 때 현재 선택한 날짜가 포함된 월이 자동으로 선택됩니다. 그러나 3개월, 반기 등과 같은 사용자 지정 날짜 범위 내에서 달력을 인쇄해야 할 수도 있습니다. 이 기사에서는 솔루션을 소개합니다.

Outlook에서 사진과 함께 연락처 인쇄
일반적으로 연락처의 사진은 Outlook에서 연락처를 인쇄 할 때 인쇄되지 않습니다. 그러나 때로는 사진과 함께 연락처를 인쇄하는 것이 더 인상적입니다. 이 기사에서는이를 수행하기위한 몇 가지 해결 방법을 소개합니다.

Outlook에서 이메일 선택 인쇄
전자 메일 메시지를 받았는데 전체 메시지를 인쇄하는 대신 인쇄해야하는 전자 메일 내용을 선택했다면 어떻게 하시겠습니까? 실제로 Outlook은 Firefox 및 Internet Explorer와 같은 인터넷 브라우저의 도움으로이 작업을 수행하는 데 도움이 될 수 있습니다. 여기에서는 인터넷 브라우저를 예로 들어 보겠습니다. 다음 튜토리얼을 참조하십시오.

"Outlook에서 인쇄"에 대한 추가 기사...


최고의 사무 생산성 도구

Outlook 용 Kutools - 귀하의 전망을 강화하는 100개 이상의 강력한 기능

🤖 AI 메일 도우미: AI 마법이 적용된 즉각적인 전문가 이메일 - 원클릭으로 천재적인 답변, 완벽한 어조, 다국어 숙달이 가능합니다. 손쉽게 이메일을 변환하세요! ...

📧 이메일 자동화: 부재중(POP 및 IMAP에서 사용 가능)  /  이메일 보내기 예약  /  이메일 발송 시 규칙에 따른 자동 참조/숨은참조  /  자동 전달(고급 규칙)   /  인사말 자동 추가   /  여러 수신자 이메일을 개별 메시지로 자동 분할 ...

📨 이메일 관리: 이메일을 쉽게 기억할 수 있습니다.  /  제목 및 기타 사기 이메일 차단  /  중복 이메일 삭제  /  고급 검색  /  폴더 통합 ...

📁 첨부 파일 프로일괄 저장  /  일괄 분리  /  일괄 압축  /  자동 저장   /  자동 분리  /  자동 압축 ...

🌟 인터페이스 매직: 😊더 예쁘고 멋진 이모티콘   /  탭 보기로 Outlook 생산성 향상  /  문을 닫는 대신 전망을 최소화하세요 ...

???? 원클릭 불가사의: 수신 첨부 파일과 함께 전체 회신  /   피싱 방지 이메일  /  🕘발신자의 시간대 표시 ...

👩🏼‍🤝‍👩🏻 연락처 및 캘린더: 선택한 이메일에서 연락처 일괄 추가  /  연락처 그룹을 개별 그룹으로 분할  /  생일 알림 제거 ...

이상 100 특징 당신의 탐험을 기다려주세요! 더 알아보려면 여기를 클릭하세요.

 

 

Comments (22)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Kan deze script ook gemaakt worden voor het verzenden van emails, dat je dan automatisch de bijlage kan laten afdrukken ?
This comment was minimized by the moderator on the site
Hello, thank you very much for the scripts, very useful indeed!
What if we wanted to print all attachments in an email in Outlook 365 web instead? Are there ways to try this?
This comment was minimized by the moderator on the site
Hi is there a way to print the email body including sender details and subject line in the script please. I pretty much need email and attachment printed out please.
This comment was minimized by the moderator on the site
Hi Mani,

If you want to print an email body including sender details and subject line, I suggest you try the Advanced Print feature of Kutools for Outlook. It can help you solve the problem easily.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/advanced-print.png?1696644946
This comment was minimized by the moderator on the site
First of all, thanks a lot for these useful VBA scripts!
My situation is as follows: I usually receive a number of emails with 2 pdf files each. One pdf file, let's call it example1.pdf, needs to be printed only once, but the second pdf file, let's call it example2.pdf, needs to be printed 3 times. The example2.pdf does not necessarily always have the same name, but there are only around 2-4 name variants, so if it were possible to tell the script to look out for a few keywords I think it would work. Is this possible?
Oh, and would it be possible to also tell the script to print the example1.pdf file as duplex?
Thanks for your help.
This comment was minimized by the moderator on the site
Hi There, thanks for publishing this

I have followed the instructions above and are running the script to print all attachments delivered.

we typically receive these in batches of 5-8 and when testing i am getting 4 out of 5 prints with one failing with error 75. All PDF's have different names and are on separate emails/ the attachements can be opened manually fine so i assume theres an issue when it tries to copy this to the temp directory. Do you have any idea how we can resolve this?
This comment was minimized by the moderator on the site
Same problem here. After a couple of emails received during a short time, it can print 3-4 pdf, but after the error 75 appear, nothing print in the same batch of mails.
This comment was minimized by the moderator on the site
Hi Gabriel,
After testing, we have reproduced the problem you encountered. the VBA scripts have been updated in the post. Please give them a try. Thanks for your feedback.
This comment was minimized by the moderator on the site
Love this script! How about if I get an email with multiple pdfs and want one copy of each. Currently when I get 3 pdf's attached, it prints the final one, 3 times, and the other 2 do not get printed. Thanks for any help!
This comment was minimized by the moderator on the site
Hi val,

Sorry for the inconvenience.
Which VBA code are you applying? VBA code 1 or VBA code 2? Do the three PDF attachments have the same name? And which Outlook version are you using?
I have tested the codes and they worked well in my case. I need to know more specific about your issue.
This comment was minimized by the moderator on the site
Is it possible to specify the printer that should be used (not the system default printer)?
I need to print 2 types of documents on 2 different printers....
Thanks for your help!
This comment was minimized by the moderator on the site
Hi Simon,
Thank you for your comment. After trying with various methods, I can't seem to get this to work. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Hello, kindly I need help, I can't integrate the script for printing pdf only.
I activated everything, the first script for generic printing works perfectly (or almost: printing pdf attachments once printed acrobat reader remains open in the background), but the specific script for pdf does not work. Thanks for posting the scripts and for any help.
Good day
This comment was minimized by the moderator on the site
Hi Marco041,
There was something wrong with the code and it has been updated. Please give it a try.
Note: we have no way to prevent Acrobat Reader from being opened because we need to use it to open the pdf document for the next print job.
Thank you for your feedback.
Sub AttachementAutoPrint(Item As Outlook.MailItem)
'Updated by Extendoffice 20220920
  Dim xFS As FileSystemObject
  Dim xTempFolder As String
  Dim xAtt As Attachment
  Dim xShell As Object
  Dim xFolder As Object, xFolderItem As Object
  Dim xFileType As String, xFileName As String
  On Error GoTo xError
  Set xFS = New FileSystemObject
  xTempFolder = xFS.GetSpecialFolder(TemporaryFolder)
  xTempFolder = xTempFolder & "\ATMP" & Format(Now, "yyyymmddhhmmss")
  MkDir (xTempFolder)
  'Set Item = Application.ActiveExplorer.Selection.Item(1)
  Set xShell = CreateObject("Shell.Application")
  Set xFolder = xShell.NameSpace(0)
  For Each xAtt In Item.Attachments
    xFileName = xAtt.FileName
    xFileType = LCase$(Right$(xFileName, VBA.Len(xFileName) - VBA.InStrRev(xFileName, ".")))
    xFileName = xTempFolder & "\" & xFileName
    xAtt.SaveAsFile (xFileName)
    Select Case xFileType
      Case "pdf"   'change "pdf" to the file extension you want to print
        Set xFolderItem = xFolder.ParseName(xFileName)
        xFolderItem.InvokeVerbEx ("print")
    End Select
  Next xAtt
'xFS.DeleteFolder (xTempFolder)
Set xFS = Nothing
Set xFolder = Nothing
Set xFolderItem = Nothing
Set xShell = Nothing
xError:
  If Err <> 0 Then
    MsgBox Err.Number & " - " & Err.Description, , "Kutools for Outlook"
    Err.Clear
  End If
Exit Sub
End Sub
This comment was minimized by the moderator on the site
Bonjour question pour vous j'ai fait les étapes pour cela mais dans les règle de message de mon outlook je ne voit pas que je peux utilisé un script
This comment was minimized by the moderator on the site
Hi STEPHANE CADORETTE,
If the “run a script” option is missing in your Rules Wizard, you can display it by following the method mentioned in this article: restore missing Run A Script pption in Outlook rule.
This comment was minimized by the moderator on the site
Bonjour moi j'ai un petit soucie lorsque j'ai fait et refait les étapes mais lorsque je créer ma règle je n'Ai pas l'option run a script.
This comment was minimized by the moderator on the site
Hi Stéphane,
If the “run a script” option is missing in your Rules Wizard, you can display it by following the method mentioned in this article: restore missing Run A Script pption in Outlook rule.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations