473,804 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CDO: Accessing message in Exchange Public Folder

20 New Member
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 3464

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

Similar topics

0
1755
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 properties specific for journal and there is no object in CDO model designed for journal items :( I have found the Redemption library that allow reading of any MAPI properties. However, it uses Outlook and MAPI objects as input. How can I get a...
14
13433
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 another PC that the database was installed on, the user is getting the message, "The project contains a missing or broken reference to the file 'CDO.DLL' version 1.21." However, I don't have a reference to cdo.dll; my reference is to cdosys.dll....
3
2882
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 all the time). There are many products that do this, but they're very expensive considering it's just for me and just for tinkering.
4
5248
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 return a list of all the addresses and names, however, when I walk through each address I cannot access the mailbox (I keep getting prompted for authentication information). Given that the long-term goal here is that the application run unattended...
4
2118
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 even do something as simple as create a new folder object. The intellisense after "CDO." doesn't seem to provide that. More importantly, I need to know if it is possible to have this code (or some code that works) NOT reside on the exchange...
2
4541
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 server. If I send part of the HTML email it will go through. If I send the whole HTML email then it gets stuck on our email server at corporate with the error: The message could not be sent to the SMTP server. The transport error code was...
2
2451
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 has some problems: - doing a Move changes the ReceivedTime of the MailItem - I can't use RichText in the MailItem.Body (only allows plain text or HTML) - some other stuff like having to use small 'tricks' to show the default signature in an email
11
2216
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 number of mail messages, reporting back to the UI thread through the use of a Queue object. When all messages that are expected have been received, each thread sends a final update to the UI and the method should exit, which should terminate the...
2
3337
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. CDO.Message objMsg; CDO.DropDirectory objDropDir = new CDO.DropDirectory(); CDO.IMessages objIMesgs; DirectoryEntry de = srUser.GetDirectoryEntry(); // Where srUser = "anup"
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.