Ankur Raj Sinha
Ankur Raj Sinha

Reputation: 1

Auto Attachment in VBS script

Set MyApp = CreateObject("Outlook.Application")
Set MyItem = MyApp.CreateItem(0) 'olMailItem

With MyItem

    .To = Vdistro
    .CC = Vregion
    .Subject = Vsubject
    .AddAttachment "C:\VzW\Ankur.txt"
    .HTMLBody = EmailComments & EmailBody & "<br><b>Regards,</b>" + mysignature
    '.Importance = Vimportance
    '.FlagStatus = Vflagstatus

on above code everything working except attachment. I have also tried MyApp..AddAttachment "C:\VzW\Ankur.txt" but no luck.

Upvotes: 0

Views: 157

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66245

The line

.AddAttachment "C:\VzW\Ankur.txt"

must be

.Attachments.Add "C:\VzW\Ankur.txt"

I bet you have On Error Resume Next somewhere. Please remove it - it masks all problems in your code.

Upvotes: 1

Related Questions