Sending latest PDF file revision to Outlook email

whoosh

New Member
Joined
May 16, 2018
Messages
17
whoosh 03:28 AM Today
Hi,

I am not very good at coding, trying to get the following code to work.
Intention is to mass send Outlook emails with PDF attachment (name =subject header) from excel list.

Example
Subject Header = 3127: Hundred Palms - To remove debris, $15000
PDF file to attach = 3127 Hundred Palms - To remove debris, $15000


1687058754378.png


VBA Code:
Sub Send_Email_From_Excel()

Dim emailApp As Object
Set emailApp = CreateObject("Outlook.Application")

Dim emailItem As Object

Path = "D:\My Files\"
QuoteNo = Range("D7")
Descrip = Range("G7")
Amount = Range("K7")
'fname = Descrip


Dim mail_list As Range
Dim cell As Range

Application.ScreenUpdating = False

On Error GoTo error_exit

Set mail_list = Range(Range("O7"), Range("O7").End(xlDown))

For Each cell In mail_list
    Set emailItem = emailApp.CreateItem(0)
    On Error Resume Next
    
    With emailItem
        .To = cell.Value
        
        '.cc = "sales@xxx.com"
        
        .Subject = Cells(cell.Row, "D").Value & ": " & Cells(cell.Row, "G").Value & ", " & "$" & Cells(cell.Row, "K").Value
        '.Subject = "Q23/" & Cells(cell.Row, "D").Value & ": " & Cells(cell.Row, "G").Value & ", " & "$" & Cells(cell.Row, "K").Value
        
        .Attachments.Add (Path & Cells(cell.Row, "D").Value & " " & Cells(cell.Row, "G").Value & ", " & "$" & Cells(cell.Row, "K").Value & ".pdf")
        
        .Body = "Dear " & Cells(cell.Row, "J").Value & "," & vbNewLine & vbNewLine & _
        "A gentle reminder for an update on the subjected mentioned" & vbNewLine & _
        "Feel free to contact us if you have any enquiries" & vbNewLine & vbNewLine & _
        "Thanks and best regards" & "," & vbNewLine & _
        "Yan"
        
        
        'Diplay the email so user can change it as desired before sending it.
        .Display
        
        'Save the email in the draft folder.
        '.Save
        
        'Send Email
        '.Send
        
    End With
    On Error GoTo 0
    Set emailItem = Nothing
    
Next cell

error_exit:
Set emailApp = Nothing

Application.ScreenUpdating = True
End Sub

Sub Remove_Q23_from_QuoteNo()
  With Range("D7", Range("D" & Rows.Count).End(xlDown))
    .Replace What:="Q23/", Replacement:="", LookAt:=xlPart
  End With
End Sub



I face problem when there is a new revision to the same quote - from Q23/3127 to Q23/3127a.
The PDF file cannot be recognised and be attached to Outlook.

I would like to email and attach the latest revision only. Would appreciate if anyone can help.
Thanks in advance.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Sending latest PDF file revision to Outlook email
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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