Attach File to Excel generated Outlook E-mail

DWRgt2885

New Member
Joined
Nov 20, 2017
Messages
25
Hey Everyone!

Can't seem to figure this one out for the life of me. I click submit, an e-mail is generated, the macro takes value's from text boxes in user form to create the "To", "Subject" & "Body" fields, but I also need it to attach the file listed in the PO text box (txtsspo.value). I've tried attachment.add and .attachment = "bla bla bla".

Not working, but the code doesn't error out either. Any suggestions?


Code:
Dim oOLook As Object
Dim oEMail As Object




Set oOLook = CreateObject("Outlook.Application")
oOLook.Session.Logon
Set oEMail = oOLook.CreateItem(0)
oEMail.Display
On Error Resume Next
With oEMail
.Importance = olImportanceHigh
.To = txtVendEML.Value
.CC = ""
.BCC = ""
.Attachment = "C:\Users\User\OneDrive - Company name llc\PO's\" & txtSSPO.Value '<----- NEED HELP HERE
.Subject = " PO# " & txtSSPO.Value
.Body = "Hi," & vbNewLine & "Attached is PO# " & txtSSPO.Value & "." & vbNewLine & _
"Please confirm estimated ship date, and your order # when you have a moment. Thank you and have a great day!" & vbNewLine & "Thanks," & vbNewLine & drpUserSingle.Value
End With
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this.
Code:
.Attachment = "C:\Users\User\OneDrive - Company name llc\PO's\" & txtSSPO.Value
 
Upvote 0
.
Perhaps he meant :

Code:
.Attachments.Add [COLOR=#333333]= "C:\Users\User\OneDrive - Company name llc\PO's\" & txtSSPO.Value[/COLOR]
 
Upvote 0
I tried both below lines of code prior to posting this, and again when these nice users suggested them. Neither worked in the sense that nothing got attached to the e-mail.. The files exist, in the path described, but nothing is being attached?

Code:
.Attachments.Add [COLOR=#333333]= "C:\Users\User\OneDrive - Company name llc\PO's\" & txtSSPO.Value
[/COLOR]
.Attachment = "C:\Users\User\OneDrive - Company name llc\PO's\" & txtSSPO.Value
</pre>
 
Upvote 0
.
Often in these cases it comes down to spelling, spacing, etc.

Re-check everything in the path description. Sometimes what appears correct is off by one letter .. one space (too much / too little) or some other tiny error.
 
Upvote 0
hmmm....I copied the Path directly from the File location properties.

When i submit my form data; the text box containing "txtsspo.value" adds the PO number to my sheet. Then it hyperlinks that cell to the document in the path "C:\Users\User\OneDrive - Company name llc\PO's"

So when i hit "Submit" on my user form i'm asking Excel to generate an e-mail, and then attach
"C:\Users\User\OneDrive - Company name llc\PO's" & txtsspo.value.....


Should i instead be asking a different way since the value on the sheet is merely a hyperlink?
 
Upvote 0
.
Try change :
Code:
[COLOR=#333333]txtSSPO.[B]Value[/B][/COLOR]

To :
Code:
[COLOR=#333333]txtSSPO.[B]Text[/B][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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