how to send only 1 attachment which is in excel cell by vba

m_vishal_c

Board Regular
Joined
Dec 7, 2016
Messages
209
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
HI i have encountered this below error. i have for example 5 email id, name and attachment path in excel file. i want to send email to them with attachment . this below code does not pick up attachment .

Please guide me

Code:
 Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
 
        toList = Cells(i, 4)    'gets the recipient name 
        eSubject = Cells(i, 8) & " " & Cells(i, 9)
        eBody = "Dear " & Cells(i, 1) & vbCrLf & vbCrLf & Cells(i, 5) & vbCrLf & vbCrLf & Cells(i, 10) & vbNewLine & vbCrLf & Cells(i, 11) & vbNewLine & Cells(i, 12) 
        
        Set rng = sh.Cells(i, 7) 'this is attachment location(path)
        
        On Error Resume Next
        With OutMail
            .To = toList
            .CC = ""
            .BCC = ""
            .Subject = eSubject
            .Body = eBody
            .bodyformat = 1
            .Attachments.Add Cells(i, 7)
            .Send 
        End With
 
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing


there are 5 email ids and 5 different attachment paths

i much appreciate yoursupport and time
thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
hi I have sorted out this query. the answer is
.Attachments.add rng.value
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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