Help with Dynamic Emails

Status
Not open for further replies.

rnick86

New Member
Joined
Dec 31, 2018
Messages
7
Hello guys, I am trying to automatically send PDF's of invoices through Outlook, and I was able to send the PDF correctly, but once I switched up the code for a Dynamic name change, I can no long get VBA to find the PDF. Below is my code:

Code:
Sub sendReminderMail()ChDir "C:\Users\rbs\Desktop"


Dim Path As String
Dim filename As String
Dim File As String


Path = "C:\Users\rbs\Desktop\Invoices\"
filename = Range("B1") & Range("C1") & " - " & Range("B9")
File = Path & filename


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
File, OpenAfterPublish:=True


Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object


Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments


With OutLookMailItem
.To = Range("B12")
.ReadReceiptRequested = True
.Subject = "Invoice #" & Range("C1")
.Body = "Thank you"
myAttachments.Add "File"
'.Send
.Display
End With


Set OutLookMailItem = Nothing
Set OutLookApp = Nothing


End Sub

I need help with the myAttachments.Add "File" line.

Any help with this, would be greatly appreciated.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Duplicate: https://www.mrexcel.com/forum/excel-questions/1082171-help-dynamic-emails.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it. Please be patient and do not attempt to post the question again.
 
Last edited:
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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