I got below code in my Word Document (office 2007) to send a
mail with attachement
It throws syntax error (file not found) at line
.Attachement.Add "C:\abc.txt"
Code:
Private Sub CommandButton1_Click()
Dim outlookapp As Object
Dim item As Object
Dim subject As String
Dim msg As String
Set outlookapp = CreateObject("outlook.application")
msg = "Enter Message here"
subject = "Enter subject here"
Set item = outlookapp.createitem(0)
With item
.to = "
[email protected] <mailto:
[email protected]> "
.subject = subject
.body = msg
.Display
.Attachments.Add "C:\abc.txt"
End With
End Sub
What am I doing wrong ?
Thanks