[dba-Tech] Cycling through Outlook Items using VBA

Susan Harkins ssharkins at setel.com
Sat Jul 14 10:54:29 CDT 2007


Marty, I'm using code. Here's what I'm currently using and it works fine,
but I am confused about a few things: 

 For intCounter = objFolder.Items.Count To 1 Step -1
  
  '-----
  'database and table can be open, but records won't show
  'up until you close and reopen table.
  '-----
  
   With objFolder.Items(intCounter)
    If .Class = olMail Then
      adoRS.AddNew
      adoRS("Subject") = .Subject
      adoRS("Body") = .Body
      adoRS("FromName") = .SenderName
      adoRS("ToName") = .To
      'adoRS("FromName") = .FromName
      'adoRS("FromAddress") = .FromAddress
      'adoRS("FromType") = .FromType
'      adoRS("ToName") = .ToName
'      adoRS("ToAddress") = .ToAddress
'      adoRS("ToType") = .ToType
'      adoRS("CCName") = .CCName
'      adoRS("CCAddress") = .CCAddress
'      adoRS("CCType") = .CCType
'      adoRS("BCCName") = .BCCName
'      adoRS("BCCAddress") = .BCCAddress
'      adoRS("BCCType") = .BCCType
'      adoRS("Importance") = .Importance
'      adoRS("Sensitivity") = .Sensitivity
      adoRS.Update
     End If
    End With
   Next


First, I simply can't get a For Each right -- I'm sure that's my
misunderstanding of the object model. I'd also rather use a second For Each
to cycle through all the current mail item's "fields" -- but can't get that
either. I tried to hard code them, but most throw an error -- as you can see
by the comment out lines. 

To learn the field names, I used the export wizard to create a target
database. I used the resulting table field names, but apparently, they don't
match Outlook's internal names -- that just doesn't make good sense to me.
:( Does anyone know of a link that maps Outlook's internal field names? I'm
totally lost. 

Susan H. 

Here is a sample of code. You'll need
to modify it to accomplish what you want exactly.
'From:         "siebeneck yon (slc1yps)" <slc1yps at UPS.COM>
Public Function ReadMail()

 




More information about the dba-Tech mailing list