Eljefegeneo
Still trying to learn
- Local time
- Today, 10:03
- Joined
- Jan 10, 2011
- Messages
- 899
While I know this subject has been posted about a thousand times, I still can't figure out what I am doing wrong. All I want to do it bring up a form from which the user can send an email, and on the form is an unbound text box [Text1] in which the user can paste the attachment path.
So, when I paste the file location into Text box [Text1] I get the Run Time error that the path does not exist or is not valid. Yet when I use the next line which is the same path, all is OK.
What am I doing wrong or rather where is my code in error. Thanks
Code:
Dim olApp As New Outlook.Application
Dim mItem As Outlook.MailItem ' An Outlook Mail item
Set olApp = CreateObject("Outlook.Application")
Set mItem = olApp.CreateItem(olMailItem)
' Add the To/Subject/Body to the message and display the message
With mItem
.To = Me.To
.CC = CC2
.BCC = BCC2
.Subject = Me.SubjectLine
.Body = Me.MessageBody
.Attachments.Add (Text1) "This produces an error"
'this next line works perfectly
' .Attachments.Add ("C:\Users\Gene\Documents\Filename.pdf")
.Display ' To show the email message to the user
End With
What am I doing wrong or rather where is my code in error. Thanks