VB6 - Email attachment not working
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.


along with the above code, Create a seperate Attacmnet object, check this code:

Dim OAttach As Outlook.Attachment
If Not IsMissing(MailAttach) Then
  Set OAttach = OutLookMail.Attachments.Add(MailAttach)
End If


Thanks for your expertise. My attachment is working now. However, I have one minor problem. See my follow-up post regarding RT Error: 424 object required.
My code bummed out on this line:

lvw.ListItems.Add , , OutlookAddressEntry.Name

Thanks again,

In my perception, I have dimensioned the object below, but have not set it; To what should I set it?

Dim OutlookAddressEntry As Outlook.AddressEntry

Set OutlookAddressEntry = ????????????? <== This maybe my problem

You can see all the previous code you gave me.