[dba-Tech] Cycling through Outlook Items using VBA

MartyConnelly martyconnelly at shaw.ca
Sat Jul 14 12:14:58 CDT 2007


Usually the error I see here is

adoRS("CCName") = .CCName
.CCName is Null and 
adoRS("CCName")doesn't allow Nulls

in the table field

Occassionally on some models like WMI but not Outlook
.CCName is defined as an array rather than a string
adoRS("CCName") = .CCName(0)
so you pass the start of the null terminated array



Susan Harkins wrote:

>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()
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada




More information about the dba-Tech mailing list