[dba-Tech] Cycling through Outlook Items using VBA

Susan Harkins ssharkins at setel.com
Sat Jul 14 13:32:35 CDT 2007


Well, here's an interesting behavior -- the wizard exports descriptions for
the Importance and Sensitivity properties, Normal shows up mostly. 

Using VBA to do the same, these properties export integers -- now I have to
find what the integers stand for. There is just no end to this...

I still don't understand why Outlook exports fields/properties manually that
I can't seem to find using VBA. 

Susan H. 

Just in case anybody's curious -- this is the code I ended up using to get
the internal field names -- I call them fields, but Outlook calls them
properties -- this code gave me properties I don't want, but I can deal with
that. It seems like these "fields" or properties should be separate from the
others and maybe there is a way to get at them without the other properties,
but I couldn't find it: 

Sub GetFieldNames()
Dim myolApp As Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim prop As Object
Set myolApp = CreateObject("Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI") Set myFolder =
myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items(2)
For Each prop In myItem.ItemProperties
  Debug.Print prop.Name
Next
End Sub

Susan H.  

-----Original Message-----
From: dba-tech-bounces at databaseadvisors.com
[mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of MartyConnelly
Sent: 14 July 2007 01:15 PM
To: Discussion of Hardware and Software issues
Subject: Re: [dba-Tech] Cycling through Outlook Items using VBA

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

_______________________________________________
dba-Tech mailing list
dba-Tech at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-tech
Website: http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.4/898 - Release Date: 2007/07/12
04:08 PM
 

_______________________________________________
dba-Tech mailing list
dba-Tech at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-tech
Website: http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.4/898 - Release Date: 2007/07/12
04:08 PM
 




More information about the dba-Tech mailing list