PDA

View Full Version : Print email and, attachments sent in hyperlinks in the email



mediocrereco
08-04-2018, 10:21 PM
Hi. I receive emails daily about registrations from a certain email address. In this email there are 1-3 links.
The link text is "Download" and it refers to a link where the files are saved.


So if there is one attachment, it will say:
some text: Download


For two it will say:
some text: Download
some text: Download


and for three:
some text: Download
some text: Download
some text: Download

What I am looking for as a vba macro is to be able to select these emails and then run the macro. The macro should print each email and then go to the link and print the attachments in these links one by one for all emails selected.

The order should be print email, print link 1 attachment, print link 2 attachment (if present), print link 3 attachment (if present), print second email, print second email attachments and so on.

I am looking for a vba solution as I don't have right to install anything else on the computer.

Appreciate your help.


I must mention here that I am completely new to outlook-vba and got the below code from searching and trial and error.
Below is the code used to print the email.



Option Explicit

Public Sub PrintDelete()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim Response As Integer
Dim msg As String
Dim strSubject As String


' Instantiate an Outlook Application object.
Set objOL = CreateObject("Outlook.Application")
' Get the collection of selected objects.
Set objSelection = objOL.ActiveExplorer.Selection

' Check selected item for attachments.
For i = objSelection.Count To 1 Step -1
objSelection(i).PrintOut
Call LaunchURL(objSelection(i).objMsg)
Next

ExitSub:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub