PDA

View Full Version : Attach Hyperlinked Documents to email



ScriptHam
10-31-2012, 03:12 AM
Hi

I have a spreadsheet with a list of hyperlinks to documents.
I have a checkbox next to each hyperlink to select the relevant ones.
I would like to attach the documents selected to an email.
Probably I would click on a command button to do this.
I can then complete the email manually and send it.

Is this possible?
Could you give me some assistance with the VBA please.

Many thanks
Scriptham

GreenDR
11-01-2012, 10:12 AM
try this:

Sub Example()
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem

On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
If oOutlook Is Nothing Then Set oOutlook = CreateObject("Outlook.Application")

Set oEmailItem = oOutlook.CreateItem(olMailItem)

With oEmailItem
.Attachments.Add Range("A1").Hyperlinks(1).Address
.Display
End With

Set oEmailItem = Nothing
Set oOutlook = Nothing

End Sub


Replace the range address per your requirement