Ana içeriğe atla

E-postalar Outlook'a ulaştığında ekleri otomatik olarak nasıl yazdırabilirim?

Bu öğretici, belirli e-postaların eklerini Outlook'a ulaştıklarında otomatik olarak yazdırmanıza yardımcı olmak için bir VBA komut dosyası ile bir Outlook kuralını birleştirme yöntemini gösterir.


Belirli e-postalar geldiğinde ekleri otomatik olarak yazdırın

Belirli bir göndericiden gelen e-postaların eklerini otomatik olarak yazdırmak istediğinizi varsayalım. Bunu yapmak için aşağıdaki gibi yapabilirsiniz.

Adım 1: Outlook'ta bir komut dosyası oluşturun

Öncelikle, Outlook'ta bir VBA komut dosyası oluşturmanız gerekir.

1. Outlook'unuzu başlatın, Ara Toplam + F11 anahtarları aynı anda açmak için Uygulamalar için Microsoft Visual Basic pencere.

2. içinde Uygulamalar için Microsoft Visual Basic pencere, üzerine çift tıklayın Project1 > Microsoft Outlook Nesneleri > Bu OutlookOturumu açmak için ThisOutlookSession (Kod) penceresini açın ve ardından aşağıdaki kodu bu kod penceresine kopyalayın.

VBA kodu 1: E-postalar geldiğinde ekleri (her tür eki) otomatik olarak yazdır

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

Not: Bu kod, e-postalarda alınan her tür ekin yazdırılmasını destekler. Yalnızca pdf dosyaları gibi belirtilen ek türünü yazdırmak istiyorsanız, lütfen aşağıdaki VBA kodunu uygulayın.

VBA kodu 2: E-postalar geldiğinde belirtilen türdeki ekleri otomatik olarak yazdırın

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

notlar:

1. Gelen e-postalarda yalnızca pdf dosyasını yazdırmak için bu VBA kodunu uygulamadan önce, önce indirip yüklemeniz gerekir. Adobe Acrobat Reader ve bilgisayarınızda varsayılan pdf okuyucu olarak ayarlayın.
2. Sırada Dava "pdf", lütfen değiştir "pdf" yazdırmak istediğiniz dosya uzantısına

3. Devam edin ve tıklayın Tools > Referanslar. Haşhaşta Referanslar – Proje1 iletişim kutusunda Microsoft Komut Dosyası Çalışma Zamanı ve ardından OK düğmesine basın.

4. Kodu kaydedin ve Ara Toplam + Q kapatmak için anahtarlar Uygulamalar için Microsoft Visual Basic pencere.

Not: Lütfen emin olun Tüm makroları etkinleştirin seçeneği Outlook'unuzda etkindir. Aşağıda gösterilen adımları izleyerek bu seçeneği kontrol edebilirsiniz.

Adım 2: Komut dosyasını kullanmak için bir kural oluşturun

Outlook'ta VBA komut dosyasını ekledikten sonra, komut dosyasını belirli koşullara göre kullanmak için bir kural oluşturmanız gerekir.

1. Ana Sayfa sekmesine gidin, kurallar > Kuralları ve Uyarıları Yönetin.

2. içinde Kurallar ve Uyarılar iletişim kutusunda, Yeni kural bir kural oluşturmak için düğmesine basın.

İpuçları: Outlook'unuza birden fazla e-posta hesabı eklediyseniz, lütfen Değişiklikleri bu klasöre uygula kuralı uygulamak istediğiniz açılır liste. Aksi takdirde, seçili e-posta hesabının gelen kutusuna uygulanacaktır.

3. İlkinde Kural Sihirbazı iletişim kutusunu seçin Alınan iletilere kural uygula içinde 1. Adım kutusunu ve sonra Tamam'ı tıklatın. Sonraki.

4. saniyede Kural Sihirbazı iletişim kutusu, yapmanız gerekenler:

4.1) Bir veya daha fazla koşul belirtin. 1. Adım ihtiyaçlarınıza göre kutu;
Bu durumda, yalnızca belirli bir göndericiden gelen e-postalardaki ekleri yazdırmak istiyorum. Burada, kontrol ediyorum insanlardan veya genel gruptan kutu.
4.2) Ekranda altı çizili değere tıklayın. 2. Adım durumu düzenlemek için kutu;
4.3) Tıklayın Sonraki. Ekran Bkz:

5. Üçüncü olarak Kural Sihirbazı iletişim kutusu, aşağıdaki gibi yapılandırmanız gerekir.

5.1) içinde Adım 1: Eylem(ler) bölümünü seçin, kontrol et bir komut dosyası çalıştır Kutu;
5.2) içinde 2. Adım bölümünde, altı çizili “bir komut dosyası” metnine tıklayın;
5.3) Açılışta Komut Dosyası Seçin iletişim kutusunda, yukarıda eklediğiniz VBA kodunun adına tıklayın ve ardından TAMAM;
5.4) Sonraki buton. Ekran görüntüsüne bakın:

İpuçları: Eğer "bir komut dosyası çalıştır” seçeneği eksik Kural Sihirbazı, bu makalede belirtilen yöntemi izleyerek görüntüleyebilirsiniz: Outlook kuralında eksik Komut Dosyası Çalıştır sayfasını geri yükle.

6. Sonra başka Kural Sihirbazı istisnalar soran açılır. Gerekirse istisnaları seçebilirsiniz, aksi takdirde Sonraki herhangi bir seçim olmadan düğme。

7. Sonunda Kural Sihirbazı, kural için bir ad belirtmeniz ve ardından Bitiş düğmesine basın.

8. Ardından, Kurallar ve Uyarılar iletişim kutusunda, oluşturduğunuz kuralın içinde listelendiğini görebilirsiniz, OK Tüm ayarları bitirmek için düğmesine basın.

Şu andan itibaren, belirtilen kişiden bir e-posta alındığında, ekli dosyalar otomatik olarak yazdırılacaktır.


İlgili Makaleler

Outlook'ta Yalnızca Bir E-postadan veya Seçilmiş E-postalardan Gelen Ekleri Yazdırın
Outlook'ta e-postaları yazdırabilirsiniz, ancak ekleri yalnızca bir e-postadan mı yoksa Outlook'ta seçilen e-postalardan mı yazdırdınız? Bu makale, bu işi çözmenin püf noktalarını tanıtmaktadır.

Outlook'ta Yalnızca Bir E-postanın İleti Başlığını Yazdır
Outlook'ta bir e-posta yazdırırken, e-postada hem mesaj başlığını hem de mesaj gövdesini yazdıracaktır. Ancak, bazı özel durumlarda, konu, gönderen, alıcılar vb. ile mesaj başlığını yazdırmanız yeterli olabilir. Bu makale bunu yapmak için iki çözüm sunacaktır.

Outlook'ta Belirtilen/Özel Tarih Aralığında Bir Takvim Yazdırın
Normalde, Outlook'ta Ay görünümünde bir takvim yazdırırken, seçili tarihi içeren ayı otomatik olarak seçer. Ancak takvimi 3 ay, yılın yarısı gibi özel bir tarih aralığında yazdırmanız gerekebilir. Bu makale size çözümü tanıtacaktır.

Outlook'ta Resimli Bir Kişiyi Yazdır
Normalde, kişi Outlook'ta yazdırılırken kişinin resmi yazdırılmaz. Ancak bazen bir kişiyi resmiyle birlikte basmak daha etkileyici olacaktır. Bu makale, bunu halletmek için bazı geçici çözümler sunacaktır.

Outlook'ta Bir E-posta Seçimi Yazdır
Bir e-posta mesajı aldıysanız ve mesajın tamamını yazdırmak yerine e-posta içeriğinin bir kısmının yazdırılması gerektiğini fark ettiyseniz, ne yapardınız? Aslında Outlook, Firefox ve Internet Explorer gibi internet tarayıcılarının yardımıyla bu işlemi gerçekleştirmenize yardımcı olabilir. Burada örneğin İnternet tarayıcılarını alacağım. Lütfen aşağıdaki eğitimlere bakın.

"Outlook'ta yazdırma" hakkında daha fazla makale...


En İyi Ofis Üretkenlik Araçları

Outlook için Kutools - Outlook'unuzu Güçlendirecek 100'den Fazla Güçlü Özellik

🤖 AI Posta Yardımcısı: Yapay zeka büyüsüyle anında profesyonel e-postalar: tek tıkla dahice yanıtlar, mükemmel ton, çok dilli ustalık. E-posta göndermeyi zahmetsizce dönüştürün! ...

???? E-posta Otomasyonu: Ofis Dışında (POP ve IMAP için kullanılabilir)  /  E-posta Gönderimini Planla  /  E-posta Gönderirken Kurallara Göre Otomatik CC/BCC  /  Otomatik İletme (Gelişmiş Kurallar)   /  Otomatik Karşılama Ekleme   /  Çok Alıcılı E-postaları Otomatik Olarak Bireysel Mesajlara Bölün ...

📨 E-posta Yönetimi: E-postaları Kolayca Geri Çağırın  /  Dolandırıcılık E-postalarını Konulara ve Diğerlerine Göre Engelleyin  /  Yinelenen E-postaları Silin  /  gelişmiş Arama  /  Klasörleri Birleştir ...

📁 Ekler ProToplu Kaydetme  /  Toplu Ayır  /  Toplu Sıkıştırma  /  Otomatik kaydet   /  Otomatik Ayır  /  Otomatik Sıkıştır ...

🌟 Arayüz Büyüsü: 😊Daha Fazla Güzel ve Havalı Emoji   /  Sekmeli Görünümlerle Outlook Verimliliğinizi Artırın  /  Outlook'u Kapatmak Yerine Küçültün ...

👍 Tek Tıklamayla Harikalar: Tümünü Gelen Eklerle Yanıtla  /   Kimlik Avına Karşı E-postalar  /  🕘Gönderenin Saat Dilimini Göster ...

👩🏼‍🤝‍👩🏻 Kişiler ve Takvim: Seçilen E-postalardan Toplu Kişi Ekleme  /  Kişi Grubunu Bireysel Gruplara Bölme  /  Doğum Günü Hatırlatıcılarını Kaldır ...

üzerinde 100 Özellikler Keşfinizi Bekleyin! Daha Fazlasını Keşfetmek İçin Buraya Tıklayın.

 

 

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