melodramatic
Board Regular
- Joined
- Apr 28, 2003
- Messages
- 187
- Office Version
- 365
- Platform
- Windows
I have tried looking up the answer to this, but somehow, I can't get this to work correctly.
I am having Excel send an email for me via vba, and after sending that email, save it to my project folder. And I obviously have not succeeded in finding the answer, as it's not working.
The Send portion is working just fine - the email goes out perfectly with the attachment. The only place where I'm having a problem is the SaveAs portion of it. It actually saved "a file" (with the correct name) to my folder, but when I tried to open the file, it came up as unreadable.
Hoping someone can give me a fix. I'm quite fine with it making me feel like I missed the obvious...
Thanks in advance!
I am having Excel send an email for me via vba, and after sending that email, save it to my project folder. And I obviously have not succeeded in finding the answer, as it's not working.
The Send portion is working just fine - the email goes out perfectly with the attachment. The only place where I'm having a problem is the SaveAs portion of it. It actually saved "a file" (with the correct name) to my folder, but when I tried to open the file, it came up as unreadable.
Hoping someone can give me a fix. I'm quite fine with it making me feel like I missed the obvious...
Thanks in advance!
Code:
'Mail DCN to DocEmail
Dim OutApp As Object
Dim OutMail As Object
Dim emailbody As String
Dim convertbody As String
Dim convertsubject As String
Dim emailsubject As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = DocEmail
.SentOnBehalfOfName = "DocCtrl@XXX.com"
.BCC = ""
.Subject = DCN
.Body = ""
.Attachments.Add (DocPath & DCN & ".pdf")
.SaveAs "X:\Document Control\PLCT Submittal\" & DCN & ".msg", 5 'THIS IS MY PROBLEM LINE THAT'S NOT WORKING
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
' END E-MAIL PORTION
LoopEnd:
Next WorkLine