Error file path in not correct while attaching in email

vinodnx

New Member
Joined
Jun 28, 2019
Messages
7
Hello I am new of VBA.
I can generate the pdf with new name every time, however i am not able to attached latest generated file in email. it is giving me me error
" Path does not exist, verify the path in correct."

here is the code. please help me expert



Sub sendReminderMail()
ChDir "C:\Users\Vinod\Desktop\Latest Billing"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
ActiveSheet.Range("Q10").Value, OpenAfterPublish:=True
filelocation = "C:\Users\Vinod\Desktop\Latest Billing"


Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Dim maildest As String


Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
maildest = ActiveSheet.Range("b18").Value


With OutLookMailItem
.To = maildest
.Subject = "Data"
.Body = "Thank you for contacting us. Your estimate can be viewed,_ printed and downloaded as PDF from the link below."
.Attachments.Add Sheets("Invoice").Range("Q10").Value & "" & ".pdf"
'.send
.Display
End With


Set OutLookMailItem = Nothing
Set OutLookApp = Nothing




End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Just guessing, but maybe:
Code:
Sub sendReminderMail()
Dim PDFfullName As String
PDFfullName = "C:\Users\Vinod\Desktop\Latest Billing\" & ActiveSheet.Range("Q10").Value & ".pdf"
ChDir "C:\Users\Vinod\Desktop\Latest Billing"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
PDFfullName, OpenAfterPublish:=True

Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Dim maildest As String


Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
maildest = ActiveSheet.Range("b18").Value


With OutLookMailItem
.To = maildest
.Subject = "Data"
.Body = "Thank you for contacting us. Your estimate can be viewed,_ printed and downloaded as PDF from the link below."
.Attachments.Add PDFfullName
'.send
.Display
End With


Set OutLookMailItem = Nothing
Set OutLookApp = Nothing

End Sub
If that doesn't work, what is the value of ActiveSheet.Range("Q10") and Sheets("Invoice").Range("Q10")? Is "Invoice" the active sheet?
 
Upvote 0
Just guessing, but maybe:
Code:
Sub sendReminderMail()
Dim PDFfullName As String
PDFfullName = "C:\Users\Vinod\Desktop\Latest Billing\" & ActiveSheet.Range("Q10").Value & ".pdf"
ChDir "C:\Users\Vinod\Desktop\Latest Billing"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
PDFfullName, OpenAfterPublish:=True

Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Dim maildest As String


Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
maildest = ActiveSheet.Range("b18").Value


With OutLookMailItem
.To = maildest
.Subject = "Data"
.Body = "Thank you for contacting us. Your estimate can be viewed,_ printed and downloaded as PDF from the link below."
.Attachments.Add PDFfullName
'.send
.Display
End With


Set OutLookMailItem = Nothing
Set OutLookApp = Nothing

End Sub
If that doesn't work, what is the value of ActiveSheet.Range("Q10") and Sheets("Invoice").Range("Q10")? Is "Invoice" the active sheet?


Thanks a lot for your time to review my request
Q10 is a variable value, which is set the file name such as "QST040601, QST040602, QST040603 ...." and and I want to attached same pdf file as Q10 cell value
Exm
Q10 cell = QST040603 eamil attached file: QST040603.pdf
Q10 cell = QST040604 eamil attached file: QST040604.pdf

Regards
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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