Macro send multiple pdf per mail.

martinus1988

New Member
Joined
Aug 13, 2015
Messages
15
Hi all,

The macro is as follows: a sheet is made and then saved as xlsx and pdf. Then outlook opens and set (only) the pdf as attachment. However i have more then 1 attachment. So the first 1 is made of an excel sheet and autopasted in the new mail. Te rest are manuals and are already in PDF. I made a list of the locations in the B colom. How do i add those files?

B colom:
R:\Verkoop\Martijn\PDF\test.pdf
R:\Verkoop\Martijn\PDF\test2.pdf
R:\Verkoop\Martijn\PDF\test3.pdf
R:\Verkoop\Martijn\PDF\test.pdf
R:\Verkoop\Martijn\PDF\test2.pdf
R:\Verkoop\Martijn\PDF\test3.pdf
R:\Verkoop\Martijn\PDF\test.pdf
R:\Verkoop\Martijn\PDF\test2.pdf
R:\Verkoop\Martijn\PDF\test3.pdf
R:\Verkoop\Martijn\PDF\test.pdf
R:\Verkoop\Martijn\PDF\test2.pdf
R:\Verkoop\Martijn\PDF\test3.pdf

<colgroup><col></colgroup><tbody>
</tbody>


See code:
Code:
Option Explicit

Sub RDB_Worksheet_Or_Worksheets_To_PDF_And_Create_Mail2()
    Dim FileName As String

    If ActiveWindow.SelectedSheets.Count > 1 Then
        MsgBox "There is more then one sheet selected," & vbNewLine & _
               "be aware that every selected sheet will be published"
    End If

    'Call the function with the correct arguments
    'Tip: You can also use Sheets("YourSheetName") instead of ActiveSheet in the code(sheet not have to be active then)

    FileName = RDB_Create_PDF(Source:=ActiveSheet, _
                              FixedFilePathName:="R:\Verkoop\Martijn\Offertes\" & ThisWorkbook.Sheets("Medewerkers").Range("I12").Value & ThisWorkbook.Sheets("Medewerkers").Range("I13").Value & ThisWorkbook.Sheets("Medewerkers").Range("I14").Value & ".pdf", _
                              OverwriteIfFileExist:=True, _
                              OpenPDFAfterPublish:=False)

    If FileName <> "" Then
        RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
                             StrTo:=ThisWorkbook.Sheets("Offerte").Range("D12").Value, _
                             StrCC:="", _
                             StrBCC:="sales@hollandaviation.com", _
                             StrSubject:="Requested quotation " & Sheets("Offerte").Range("H7").Value, _
                             Signature:=True, _
                             Send:=False, _
                             StrBody:="[B][B]Dear " & Sheets("Offerte").Range("D7").Value & "[/B][/B]


" & _
                                      "Thank you for your interest in XXXX." & _
                                      "

" & "We have made the quotation you asked for. please check attachment." & _
                                      "

" & "If you have further question, then please let us know."
    'Zet de Send:=True, _) aan om mnail gelijk te verzenden!

    Else
        MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
               "Microsoft Add-in is not installed" & vbNewLine & _
               "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
               "The path to Save the file in arg 2 is not correct" & vbNewLine & _
               "You didn't want to overwrite the existing PDF if it exist"
    End If
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top