Hello!
I hope someone can help me.
I have following macro, that sends an email from Word document. It places prederermined text, subject line and email address into email. The only issue I'm having, is that I'm unable to tell macro to grab a pdf document from the specific location(web-site) and add it as an attachment to my document.
Here's part of the macro I'm working on right now
Code
sub email
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
'Create a new message
Set oItem = oOutlookApp.CreateItem(olMailItem)
'Copy the open document
Selection.WholeStory
Selection.Copy
Selection.End = True
'Set the WordEditor
Dim objInsp As Outlook.Inspector
Dim wdEditor As Word.Document
Set objInsp = oItem.GetInspector
Set wdEditor = objInsp.WordEditor
Dim objRecip As Outlook.recipient
'Write the intro if specified
Dim i As Integer
Dim myRange, strMsg, res As Variable
'Write the intro above the signature
Set myRange = ActiveDocument.Range
wdEditor.Characters(1).Paste
i = wdEditor.Characters.Count
wdEditor.Characters(i + 1).InsertParagraph
i = i + 2
'Pop up box asking for the merchant's email address
Dim recipient As String
recipient = InputBox("Please enter an email address")
If recipient = Empty Then
recipient = InputBox("This field cannot be empty! Please enter the merchant's email address:")
oCC.Range.Text = recipient
If recipient = Empty Then
msgbox1 = msgbox("This field cannot be empty! Please reopen the document and try again")
ActiveDocument.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
End
End If
End If
Set objRecip = oItem.Recipients.Add(recipient)
objRecip.Type = olTo
'Display the email and send it
Set objRecip = oItem.Recipients.Add(recipient)
objRecip.Type = olBCC
oItem.Display
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Do you want still to send the message?"
res = msgbox(strMsg, vbYesNo + vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Exit Sub
End If
End If
oItem.Subject = "Subject line here"
'The body of this message will be
'the content of the active document.
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set objInsp = Nothing
Set wdEditor = Nothing
End Sub
Display More