Advertisement

05.29.2008 at 01:01PM PDT, ID: 23442761
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Email not moving when using CDO Message object and MoveTo method

Asked by bcullinan in Visual Basic Programming

Tags:

I've written some VB code to get an email message from the Inbox of a group mailbox on the Exchange Server (without using Outlook) and move it to a subfolder.  I'm having difficulty getting the email to move.

I have two functions, one returns the folder's ID and the other does the moving.  Here is the function to capture the folder ID:

Public Function GetFolderID(FolderName As String) As String
Dim lcdoFolders  As Folders
Dim lcdoFolder   As Folder
Dim lbFound      As Boolean
Dim lstrFolderID As String
   
On Error GoTo ErrorHandler

    Set lcdoFolders = gcdoInbox.Folders

    lbFound = False
    Set lcdoFolder = lcdoFolders.GetFirst
    Do While (Not lbFound) And Not (lcdoFolder Is Nothing)
        Debug.Print lcdoFolder.Name
        If lcdoFolder.Name = FolderName Then
            lbFound = True
            lstrFolderID = lcdoFolder.FolderID
            Debug.Print lstrFolderID
            Exit Do
        Else
            Set lcdoFolder = lcdoFolders.GetNext
            lstrFolderID = ""
        End If
    Loop
   
    Set lcdoFolder = Nothing
    Set lcdoFolders = Nothing
    GetFolderID = lstrFolderID
    Exit Function
   
ErrorHandler:
    MsgBox Err.Number & " " & Err.Description
    If Not (lcdoFolder Is Nothing) Then
        Set lcdoFolder = Nothing
    End If
    If Not (lcdoFolders Is Nothing) Then
        Set lcdoFolders = Nothing
    End If
    Exit Function

End Function

This function is supposed to move the mail to a subfolder but doesn't.  The MoveToFldrID argument was populated by the function above.

Public Function MoveEmail(MoveToFldrID As String) As Boolean
Dim lcdoMovedMsg As Message

On Error GoTo ErrorHandler
   
    Set lcdoMovedMsg = gcdoMessage.MoveTo(MoveToFldrID)
    Set lcdoMovedMsg = Nothing
    MoveEmail = True
    Exit Function
   
ErrorHandler:
    MsgBox Err.Number & " " & Err.Description
    If Not (lcdoMovedMsg Is Nothing) Then
        Set lcdoMovedMsg = Nothing
    End If
    MoveEmail = False
    Exit Function

GetFolderID is called from a Sub and its return value is used by MoveEmail in the same Sub.  In that same Sub, the gcdoMessage object is set as such:

    Set gcdoInbox = gcdoSession.Inbox
    Set gcdoMessages = gcdoInbox.Messages
    Set gcdoMessage = gcdoMessages.GetFirst

The lcdoMovedMsg contains the Subject of the message that is being moved.  Does anybody have any idea why the message is not getting moved.  I'm at a loss.
Start Free Trial
[+][-]05.30.2008 at 06:34PM PDT, ID: 21682381

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 06:35PM PDT, ID: 21682384

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.01.2008 at 10:52AM PDT, ID: 21687843

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 11:29PM PDT, ID: 21905322

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Tags: Visual Basic
Sign Up Now!
Solution Provided By: robberbaron
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628