VB6 - Email attachment not working
Hi,
I wrote this program to send email through VB. The email is working okay but the attachment I need to attach to the email is not being attached.
See my codes below:
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
Set NSpace = OutlookApp.GetNamespace("MAPI")
Set OutlookContacts = NSpace.GetDefaultFolder _(olFolderContacts).Items
MailAttach = "C:\ProjectStatus.xls" <-- This spreadsheet resides in my hard drive.
OutlookMail.To = EmailID
OutlookMail.Subject = "Project Status"
OutlookMail.Body = "This is VB email test"
If Len(MailAttach) = 0 Then
OutlookMail.Attachments.Add MailAttach '"C:\ProjectStatus.xls"
End If
'OutlookMail.Display 'To display the email
OutlookMail.Send 'To send the email
Set OutlookApp = Nothing
Set OutlookMail = Nothing
Any assistance will be appreciated.
tgifgemini