473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

CDO: Accessing message in Exchange Public Folder

Hello all

I am trying to modify a CDO script that moves email messages out of a user's inbox and into a drop folder. I want to update it to use a Public Folder instead.

The portion of the original script that matters is:

Expand|Select|Wrap|Line Numbers
  1. ' URL used for Outlook Web Access
  2. strOWAURL = "http://servername/exchange/"
  3.  
  4. ' Login
  5.  
  6. Set objUserSess = CreateObject("MAPI.Session")
  7. objUserSess.Logon  , , , , , , strServerName & vbLF & strAccountName
  8.  
  9. ' Move each message
  10.  
  11. Set objFolder = objUserSess.Inbox
  12. For each objMsg in objFolder.Messages
  13.     for each strMsgField in objMsg.fields
  14.         if instr(strMsgField,"/Inbox/") > 0 then
  15.             set objWebMsg = createobject("CDO.Message") 
  16.             objWebMsg.datasource.open strOWAURL& strMailBoxName  & strMsgField
  17.             set stm = objWebMsg.getstream() 
  18.             stm.type = 2
  19.             stm.Charset = "x-ansi"
  20.             rfcmsg = stm.readtext
  21.             rfcmsg = "x-sender: " & objWebMsg.fields("urn:schemas:httpmail:from") & vbcrlf & rfcmsg
  22.             rfcmsg = "x-receiver: " &strListEmail & vbcrlf & rfcmsg
  23.             stm.position = 0 
  24.             stm.writetext = rfcmsg
  25.             stm.savetofile strPickupFolder & objMsg.ID  & ".eml"
  26.         end if
  27.     next
  28.     objMsg.Delete
  29. next
  30.  
My modified script is:

Expand|Select|Wrap|Line Numbers
  1. ' URL used for Outlook Web Access
  2. strOWAURL = "http://localhost/public/testfolder/"
  3.  
  4. Set objSession = CreateObject("MAPI.Session")
  5. objSession.Logon  , , , , , , strServerName & vbLF & strAccountName
  6.  
  7. ' Change from a user inbox to the Public Folder infostore
  8.  
  9. Set objInfoStores = objSession.InfoStores
  10. Set objInfoStore = objInfoStores.Item("Public Folders")
  11. Set objRootFold = objInfoStore.RootFolder
  12.  
  13. Set objFolder = objRootFold.Folders(2).Folders("TestFolder")
  14.  
  15. For each objMsg in objFolder.Messages
  16.     for each strMsgField in objMsg.fields
  17.  
  18.             ' deleted line if instr(strMsgField,"/Inbox/") > 0 then
  19.             ' couldn't see the relevance in a Public Folder
  20.             ' with no subfolders
  21.  
  22.             set objWebMsg = createobject("CDO.Message") 
  23.  
  24.             ' this is the line that doesn't work below
  25.             ' the error is that it can't find the message
  26.  
  27.             objWebMsg.datasource.open strOWAURL & strMsgField
  28.  
So my question is, how can I open the message with the datasource.open method, given that we are now talking about a message object in a public folder, not a user's inbox?

I'm totally new to VB, so if I have made some outrageous and/or idiotic error, then I am not surprised (and I apologise in advance!).

Thanks for your help.
Jan 2 '09 #1
0 3439

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Oleg Safronov via .NET 247 | last post by:
I'm trying to read properties of journal item which is stored in Exchange public folder. I already have access to journal item via CDO.Item object. However, it does not allow reading of...
14
by: Neil Ginsberg | last post by:
I am using VBA/Access to send SMTP mail using CDO. I set a reference to "Microsoft CDO for Windows 2000 Library" (cdosys.dll). Everything works fine, both on my PC and on another PC. However, on...
3
by: Chad Myers | last post by:
I'm looking for an app that would allow me to download mails from various POP3 accounts and put them into my Exchange inbox on the server side (rather than having to have outlook open to do it...
4
by: Noonan, Derek | last post by:
Hi all, I'm reposting this, as I feel that it may have got buried. If anyone can help me then I'd really appreciate it... I am trying to read information from the GAL using C#. I am able to...
4
by: Ripley | last post by:
I have seen this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_hosting_createpublicfolder.asp I can't seem to make the conversion to C# - I don't see how to...
2
by: | last post by:
How can I force SmtpMail class to use CDO for Windows 2000 instead of Exchange 2000. We do not use Exchange at all. I want to do this because I am having a problem sending email from the web...
2
by: Pieter | last post by:
Hi, I'm using a thight integration with Outlook 2003 (with an Exchange server) in my VB.NET (2005) application. Until now I'm using the Outlook Object Model, but it appears to be very slow, and...
11
by: Steve Smith | last post by:
I have written a winforms application that launches approximately 150 threads with Thread.ThreadStart() Each thread uses CDO 1.21 to logon to a different Exchange mailbox and send/receive a...
2
by: anup wadekar | last post by:
I am able to access the exchange mail boxes of the mounted edb file using Active Directory Services such that i am retrieving the names of the user's and than setting the mail box to the user. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.