944,025 Members | Top Members by Rank

Ad:
Jul 23rd, 2007
0

VB6 - Outlook Email set up - Error 424: Object required

Expand Post »
Hello everyone,
I am having a problem completing my outlook email setup through VB.
I am gettin Run-time error 424 - Object required:
Actually someone got me to this point, but I'm bumming out on this line:
"lvw.ListItems.Add , , OutlookAddressEntry.Name" - basically all the lines that have the prefix "lvw." because I don't know where that prefix is coming from.
Also, the "OutlookAddressEntry" is not set.
Please help.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim OutlookApp As Object
  2. Dim OutlookMailItem As Outlook.MailItem
  3. Dim OutlookAddressList As Outlook.AddressList
  4. Dim OutlookAddressEntry As Outlook.AddressEntry
  5. Dim MailAttach As String
  6. Dim OutlookNSpace As Outlook.NameSpace
  7. Dim OutlookAttach As Outlook.Attachment
  8.  
  9. MailAttach = "C:\ProjectStatus.xls"
  10.  
  11. 'Send Email using outlook application
  12. 'Note: outlook must be installed on your PC for this module to work:
  13. '-------------------------------------------------------------------
  14. Set OutlookApp = New Outlook.Application
  15. Set OutlookMailItem = OutlookApp.CreateItem(0)
  16. Set OutlookNSpace = OutlookApp.GetNamespace("MAPI")
  17.  
  18.  
  19. 'Get email address from global email address folder
  20. '--------------------------------------------------
  21. For Each OutlookAddressList In OutlookNSpace.AddressLists
  22. For Each OutlookAddressEntry In OutlookAddressList.AddressEntries
  23. lvw.ListItems.Add , , OutlookAddressEntry.Name
  24. lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address
  25. lvw.ListItems(lvw.ListItems.Count).SubItems(2) = OutlookAddressEntry.ID
  26. lvw.ListItems(lvw.ListItems.Count).Tag = OutlookAddressEntry.ID
  27. Next
  28. Next
  29.  
  30. EmailID = lvw.ListItems(lvw.ListItems.Count).SubItems(1)
  31.  
  32. If Trim(EmailID) <> "" And Trim(EmailID) Like "*@*.*" Or Trim(EmailID) Like "*@*.com" Then
  33. GoTo SENDEMAIL
  34. Else
  35. MsgBox ("You have entered an invalid email address"), vbCritical, "Email Address Error!"
  36. Exit Sub
  37. End If
  38.  
  39.  
  40. SENDEMAIL:
  41. OutlookMailItem.To = EmailID
  42. OutlookMailItem.Subject = "Project Status"
  43. OutlookMailItem.Body = "This is VB email test"
  44.  
  45. If Not IsMissing(MailAttach) Then
  46. Set OutlookAttach = OutlookMailItem.Attachments.Add(MailAttach)
  47. End If
  48.  
  49. 'If Len(MailAttach) > 0 Then
  50. ' OutlookMailItem.Attachments.Add "C:\ProjectStatus.xls", olByValue, 1, "ProjectStatus"
  51. 'End If
  52.  
  53. 'OutlookMailItem.Display 'To display the email
  54. OutlookMailItem.Send 'To send the email
  55.  
  56. Set OutlookApp = Nothing
  57. Set OutlookMailItem = Nothing

Thanks,
tgifgemini
Similar Threads
Reputation Points: 22
Solved Threads: 0
Junior Poster
tgifgemini is offline Offline
113 posts
since Jul 2007
Jul 24th, 2007
0

Re: VB6 - Outlook Email set up - Error 424: Object required

do you have a listview named lvw?
Reputation Points: 10
Solved Threads: 0
Light Poster
planethax is offline Offline
34 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: plssss help me ..... it is about function
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: about combo box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC