Send attachments

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Send attachments

Post by VegasNath »

I am using the following code to send attachments:

Code: Select all

Dim lr2 As Long, lr3 As Long, lr4 As Long, lr5 As Long, lr6 As Long
lr2 = ws2.Cells(1, 1).End(xlDown).row
'...........

    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    
    With OutMail
        .To = "Fred"
        .Subject = "Files"
        .HTMLBody = StrBody
        .Attachments.Add wb2.FullName
        .Attachments.Add wb3.FullName
        .Attachments.Add wb4.FullName
        .Attachments.Add wb5.FullName
        .Attachments.Add wb6.FullName
        .Send
    End With
I only want to send each attachment (for example)..... If lr2 - 1 > 0, send wb2. etc.....

How can I achieve this?
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78665
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Send attachments

Post by HansV »

Code: Select all

    If lr2 - 1 > 0 Then
        .Attachments.Add wb2.FullName
    End If
etc.
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Send attachments

Post by VegasNath »

Cheers Hans, I was somewhat over complicating the obvious.
:wales: Nathan :uk:
There's no place like home.....