Skip to main content

Conas ceangaltáin a phriontáil go huathoibríoch nuair a shroicheann ríomhphoist Outlook?

Léiríonn an teagasc seo modh chun script VBA agus riail Outlook a chomhcheangal chun cabhrú leat ceangaltáin de ríomhphoist áirithe a phriontáil go huathoibríoch nuair a thagann siad go Outlook.


Priontáil ceangaltáin go huathoibríoch nuair a thagann ríomhphoist áirithe isteach

Ag cur san áireamh, ba mhaith leat ceangaltáin ríomhphoist a thagann isteach ó sheoltóir áirithe a phriontáil go huathoibríoch. Is féidir leat a dhéanamh mar seo a leanas chun é a dhéanamh.

Céim 1: Cruthaigh script in Outlook

Ar an gcéad dul síos, ní mór duit script VBA a chruthú in Outlook.

1. Seoladh do Outlook, brúigh an Eile + F11 eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fhuinneog, cliceáil faoi dhó ar Project1 > Microsoft Outlook Object > ThisOutlookSession a oscailt ThisOutlookSession (Cód) fhuinneog, agus ansin cóipeáil an cód seo a leanas isteach sa fhuinneog cód seo.

Cód VBA 1: Priontáil ceangaltáin go huathoibríoch (gach cineál ceangaltán) nuair a thagann ríomhphoist

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

Nóta: Tacaíonn an cód seo le priontáil gach cineál ceangaltán a fhaightear i ríomhphoist. Más mian leat an cineál ceangaltán sonraithe a phriontáil, mar shampla comhaid pdf, cuir an cód VBA seo a leanas i bhfeidhm.

Cód VBA 2: Priontáil go huathoibríoch ar an gcineál sonraithe ceangaltán nuair a thagann ríomhphoist

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

nótaí:

1. Sula gcuireann tú an cód VBA seo i bhfeidhm chun an comhad pdf a phriontáil ach amháin sna ríomhphoist atá ag teacht isteach, ar dtús is gá duit a íoslódáil agus a shuiteáil Adobe Acrobat Reader agus socraigh é mar an léitheoir pdf réamhshocraithe ar do ríomhaire.
2. Sa líne Cás "pdf", athraigh le do thoil "pdf" chuig an síneadh comhad is mian leat a phriontáil.

3. Téigh ar aghaidh agus cliceáil uirlisí > Tagairtí. Sa popping suas Tagairtí – Tionscadal1 bosca dialóige, seiceáil an Microsoft Scripting Runtime bosca, agus ansin cliceáil ar an OK cnaipe.

4. Sábháil an cód agus brúigh an Eile + Q eochracha chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

Nóta: Cinntigh le do thoil go bhfuil an Cumasaigh gach macra Tá an rogha cumasaithe i do Outlook. Is féidir leat an rogha seo a sheiceáil trí na céimeanna a thaispeántar thíos a leanúint.

Step2: Tóg riail chun an script a úsáid

Tar éis duit an script VBA a chur leis in Outlook, ní mór duit riail a chruthú chun an script a úsáid bunaithe ar choinníollacha áirithe.

1. Téigh go dtí an Baile tab, cliceáil Rialacha > Bainistigh Rialacha & Foláirimh.

2. Sa Rialacha agus Foláirimh bosca dialóige, cliceáil an Riail Nua cnaipe chun riail a chruthú.

Leid: Má tá cuntais ríomhphoist iolracha curtha agat le do Outlook, sonraigh le do thoil cuntas sa Cuir athruithe i bhfeidhm ar an bhfillteán seo liosta anuas áit ar mhaith leat an riail a chur i bhfeidhm. Seachas sin, cuirfear i bhfeidhm é ar bhosca isteach an chuntais ríomhphoist atá roghnaithe faoi láthair.

3. Sa chéad cheann Draoi Rialacha dialóg, roghnaigh Cuir riail ar na teachtaireachtaí a bhfaighidh mé sa 1 Céim bosca, agus ansin cliceáil Seo chugainn.

4. Sa dara ceann Draoi Rialacha bosca dialóige, ní mór duit:

4.1) Sonraigh coinníoll amháin nó níos mó sa 1 Céim bosca de réir do riachtanas;
Sa chás seo, ba mhaith liom a phriontáil ach na ceangaltáin i ríomhphoist ag teacht isteach ó seoltóir sonraithe. Anseo, seiceáilim an ó dhaoine nó ó ghrúpa poiblí bosca.
4.2) Cliceáil ar an luach a bhfuil líne faoi sa 2 Céim bosca chun an riocht a chur in eagar;
4.3) Cliceáil Seo chugainn. Féach an pictiúr:

5. Sa tríú Draoi Rialacha bosca dialóige, ní mór duit a chumrú mar seo a leanas.

5.1) Sa Céim 1: Roghnaigh gníomh(í) alt, seiceáil an script a rith bosca;
5.2) Sa 2 Céim alt, cliceáil ar an téacs a bhfuil líne faoi “script”;
5.3) San oscailt Roghnaigh Script bosca dialóige, cliceáil ar ainm an chóid VBA a chuir tú leis thuas, agus ansin cliceáil Ceart go leor;
5.4) Cliceáil ar an Ar Aghaidh cnaipe. Féach an pictiúr:

Leid: Má tá an “script a rithTá rogha " ar iarraidh i do Draoi Rialacha, is féidir leat é a thaispeáint tríd an modh a luaitear san Airteagal seo a leanúint: a chur ar ais ar iarraidh Rith A Script ption i riail Outlook.

6. Ansin ceann eile Draoi Rialacha pop suas ag iarraidh eisceachtaí. Is féidir leat na heisceachtaí a roghnú más gá, ar shlí eile, cliceáil ar an Ar Aghaidh cnaipe gan aon roghanna.

7. Sa cheann deireanach Draoi Rialacha, ní mór duit ainm a shonrú don riail, agus ansin cliceáil ar an Críochnaigh cnaipe.

8. Ansin filleann sé ar an Rialacha agus Foláirimh bosca dialóige, is féidir leat an riail a chruthaigh tú atá liostaithe taobh istigh a fheiceáil, cliceáil ar an OK cnaipe chun na socruithe iomlána a chríochnú.

As seo amach, nuair a fhaightear ríomhphost ón duine sonraithe, déanfar na comhaid a ghabhann leis a phriontáil go huathoibríoch.


Earraí gaolmhara

Priontála Amháin Ceangaltán(S) Ó Ríomhphost Amháin Nó Ríomhphoist Roghnaithe In Outlook
In Outlook, is féidir leat na ríomhphoist a phriontáil, ach an ndearna tú na ceangaltáin a phriontáil ó r-phost amháin nó ríomhphoist roghnaithe in Outlook? Tugann an t-alt seo isteach na cleasanna maidir leis an bpost seo a réiteach.

Priontáil Ceanntásc Teachtaireacht amháin de Ríomhphost In Outlook
Agus ríomhphost á phriontáil in Outlook, déanfaidh sé ceanntásc teachtaireachta agus comhlacht teachtaireachta sa ríomhphost a phriontáil. Mar sin féin, i gcásanna speisialta áirithe, b'fhéidir nach mbeadh ort ach ceanntásc na teachtaireachta a phriontáil leis an ábhar, an seoltóir, na faighteoirí, etc. Tabharfaidh an t-alt seo isteach dhá réiteach chun é a dhéanamh.

Priontáil Féilire I Raon Dáta Sonraithe/Saincheaptha In Outlook
De ghnáth, nuair a bhíonn féilire á phriontáil i Month view in Outlook, roghnóidh sé go huathoibríoch an mhí ina bhfuil an dáta roghnaithe faoi láthair. Ach, b'fhéidir go mbeadh ort an féilire a phriontáil laistigh de raon dáta saincheaptha, mar shampla 3 mhí, leath na bliana, etc. Tabharfaidh an t-alt seo an réiteach isteach duit.

Priontáil Teagmháil Le Pictiúr In Outlook
De ghnáth, ní phriontálfar pictiúr teagmhálaí nuair a phriontálfar an teagmháil in Outlook. Ach uaireanta, beidh sé níos suntasaí teagmháil lena phictiúr a phriontáil. Tabharfaidh an t-alt seo roinnt réimsí oibre isteach chun é a chur i gcrích.

Priontáil Roghnú Ríomhphost In Outlook
Má fuair tú teachtaireacht ríomhphoist agus má fuair tú amach go bhfuil rogha den ábhar ríomhphoist is gá a phriontáil amach in ionad an teachtaireacht iomlán a phriontáil, cad a dhéanfá? I ndáiríre, is féidir le Outlook cabhrú leat an oibríocht seo a bhaint amach le cabhair ó bhrabhsálaithe idirlín, mar an Firefox agus an Internet Explorer. Tógfaidh mé na brabhsálaithe Idirlín anseo mar shampla. Féach ar na ranganna teagaisc seo a leanas, le do thoil.

Tuilleadh alt faoi "priontáil in Outlook"...


Uirlisí Táirgiúlachta Oifige is Fearr

Kutools le haghaidh Outlook - Níos mó ná 100 Gnéithe cumhachtacha chun do Outlook a shárú

🤖 Cúntóir Ríomhphoist AI: Ríomhphoist pro toirt le draíocht AI - aon-cliceáil chun freagraí genius, ton foirfe, máistreacht ilteangach. Trasfhoirmigh ríomhphost gan stró! ...

📧 Uathoibriú Ríomhphoist: As Oifig (Ar fáil do POP agus IMAP)  /  Sceideal Seol Ríomhphoist  /  Auto CC/BCC de réir Rialacha Agus Ríomhphost á Sheoladh  /  Auto Ar Aghaidh (Ardrialacha)   /  Beannacht Auto Cuir leis   /  Scoilt Ríomhphoist Ilfhaighteoirí go huathoibríoch i dTeachtaireachtaí Aonair ...

📨 Bainistíocht Ríomhphost: Ríomhphoist a Athghairm go héasca  /  Bloc Ríomhphoist Scam ag Ábhair agus Daoine Eile  /  Scrios Ríomhphoist Dúblacha  /  Cuardach Casta  /  Comhdhlúthaigh Fillteáin ...

📁 Ceangaltáin ProSábháil Baisc  /  Baisc Dícheangail  /  Comhbhrú Baisc  /  Auto Sábháil   /  Auto Dícheangail  /  Comhbhrúite Auto ...

🌟 Draíocht Chomhéadain: 😊Níos mó Emojis Pretty and Cool   /  Treisiú Do Tháirgiúlacht Outlook le Radhairc Tabbed  /  Íoslaghdaigh Outlook In ionad Deiridh ...

???? Wonders aon-cliceáil: Freagair Gach Duine le Ceangaltáin Isteach  /   Ríomhphoist Frith-Iascaireachta  /  🕘 Taispeáin Crios Ama an tSeoltóra ...

👩🏼‍🤝‍👩🏻 Teagmhálaithe & Féilire: Baisc Cuir Teagmhálacha Ó Ríomhphoist Roghnaithe  /  Roinn Grúpa Teagmhála ar Ghrúpaí Aonair  /  Bain Meabhrúcháin Breithlá ...

Thar Gnéithe 100 Fan le do Thaiscéalaíocht! Cliceáil Anseo le Tuilleadh Amach.

 

 

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