exchangefreaks.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CDO Fields

 
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Applications
Author Message
Emmett



Joined: 05 Aug 2007
Posts: 2

PostPosted: Wed Mar 02, 2005 3:40 pm    Post subject: CDO Fields Reply with quote

Hi,

I want to import Outlook messages, including the header, into Access.
Accessing most fields is straightforward but I'm having problems
mapping the to/recipient field. When I use something like 'rst!To =
oMessage.Recipients' I get a 450 error message 'wrong number of
arguments or invalid property assignment.

I'm sure that the answer is staring me in the face but I can't see
it. Any help would be appreciated. I set out my code below.

Thanks in advance for any help.

Regards

Emmett

##################Code#################


Private Sub LoadEmails()

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblEmails")

Dim oSession As MAPI.Session
Dim oFolder As Folder
Dim oMsgColl As Messages
Dim oMessage As Message
Dim c As Outlook.MailItem

' Logon to the MAPI session
Set oSession = New MAPI.Session
oSession.Logon

' Get the Inbox folder and its message collection.
Set oFolder =
oSession.GetDefaultFolder(CdoDefaultFolderInbox).Folders("Emails").Folders("ToImport")

Set oMsgColl = oFolder.Messages

For Each oMessage In oMsgColl

rst.AddNew

rst!Subject = oMessage.Subject
rst!Sender = oMessage.Sender
rst!Body = oMessage.Text
---------> rst!To = oMessage.Recipients <--------------------------
rst!ReceivedTime = oMessage.TimeReceived
rst!Header = oMessage.Fields(&H7D001E)

rst.Update

Next


' Logoff and cleanup
oSession.Logoff
Set oSession = Nothing
Set oMessage = Nothing
Set oMsgColl = Nothing
Set oFolder = Nothing

End Sub

Archived from group: microsoft>public>exchange>applications
Back to top
View user's profile Send private message
Dan Mitchell



Joined: 05 Aug 2007
Posts: 42

PostPosted: Wed Mar 02, 2005 8:02 pm    Post subject: Re: CDO Fields Reply with quote

Emmett@Silico-Research.com wrote in@z14g2000cwz.googlegroups.com:
> I want to import Outlook messages, including the header, into Access.
> Accessing most fields is straightforward but I'm having problems
> mapping the to/recipient field. When I use something like 'rst!To =
> oMessage.Recipients' I get a 450 error message 'wrong number of
> arguments or invalid property assignment.
> [snip]
> ---------> rst!To = oMessage.Recipients <--------------------------

The Recipients property of a message is a collection of Recipient
items, not just a string containing their email addresses/names.

You'll need something like (not sure of exactly what syntax Access is
expecting)

dim oRecipients as MAPI.Recipients
dim oRecipient as MAPI.Recipient
set oRecipients = oMessage.Recipients
for each oRecipient in oRecipients

process oRecipient however you want -- append oRecipient.Name to
rst!To or something, depends on your app's requirements. Probably want
to check if (recipient.type == CdoTo) as well if you only want the To
recipients -vs- cc: recipients.

next

-- dan
Back to top
View user's profile Send private message
Emmett



Joined: 05 Aug 2007
Posts: 2

PostPosted: Thu Mar 03, 2005 1:39 pm    Post subject: Re: CDO Fields Reply with quote

Dan,

That works. Thanks.

Regards

Emmett

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Applications All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group