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

Reply

Join Date: Jul 2007
Posts: 113
Reputation: tgifgemini is an unknown quantity at this point 
Solved Threads: 0
tgifgemini tgifgemini is offline Offline
Junior Poster

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

 
0
  #1
Jul 23rd, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: planethax is an unknown quantity at this point 
Solved Threads: 0
planethax planethax is offline Offline
Newbie Poster

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

 
0
  #2
Jul 24th, 2007
do you have a listview named lvw?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC