hi there
I am having a few problems attaching multiple documents using a macro here is the data i am currently using to produce an email and attach a pdf doc and then send off to clients, i am just wondering if anyone can help with adding multiple pdf attachments using this macro (if that makes sense)
Sub sendemail()
Dim Answer As Variant
Dim FileToAttach As Variant
Dim Msg As String
Dim MyApp As Boolean
Dim olApp As Object
Dim olEmail As Object
Dim SendTo As String
Dim Subj As String
Dim InsertSig As String
'Outlook constants aren't available using late binding
Const olByValue = 1
Const olMailItem = 0
'Setup email variables using worksheet cells F8, K8, B40 AND B41
SendTo = Cells(8, "F").Text 'F8
Subj = Cells(8, "K").Text 'K8
Msg = "Dear," & Cells(41, "B").Text
'Select a file to attach to the email
FileFilter = "All Files, *.*,CSV Files, *.csv,Excel Files, *.xls;*.xlt;*.xla"
FileToAttach = Application.GetOpenFilename(FileFilter:=FileFilter, Title:="C:\Documents and Settings\David\Desktop\Copy of ccb quote calculators\calculator\telecomsproposal.pdf")
'Was Cancel selected?
If FileToAttach = False Then
Answer = MsgBox("Do you still want to send an email?", vbYesNo + vbQuestion)
If Answer = vbNo Then Exit Sub
End If
'Open or Start Outlook
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err = 429 Then
MyApp = True
Set olApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
olApp.Session.Logon
'Create an Outlook Mail Item
Set olEmail = olApp.CreateItem(olMailItem)
On Error Resume Next
With olEmail
.To = SendTo
.Subject = Subj
.Body = Msg
.Attachments.Add FileToAttach, olByValue
.Send
End With
If Err <> 0 Then
MsgBox "The following error occurred while sending the email..." & vbCrLf _
& "(" & Err.Number & ") " & Err.Description
End If
olApp.Session.logoff
If MyApp Then olApp.Quit
'Release Objects
Set olApp = Nothing
Set olEmail = Nothing
Can anyone help please
regards
David
Bookmarks