Solved

Moving a mail message from inbox to a custom folder

Posted on 1998-12-02
4
159 Views
Last Modified: 2010-08-05
I am writting a VB program that loops thru all the emails in Outlook 97's "Inbox" folder and then moves some to a special folder that I created called "Processed UnitedWay Pledges." I cannot move the emails from the inbox to my special folder. Does anyone know how I might accomplish this task? Everything else is working fine.
Thanks!
0
Comment
Question by:beaumont
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:beaumont
ID: 1447887
Edited text of question
0
 

Author Comment

by:beaumont
ID: 1447888
Edited text of question
0
 
LVL 2

Accepted Solution

by:
cedricd earned 50 total points
ID: 1447889
*** Login Function Outlook_LOGIN() As Boolean    On Error GoTo Outlook_Login_Err
        Set theApp = CreateObject("Outlook.Application")
    Set theNameSpace = theApp.GetNamespace("MAPI")    MAILBOX_STATE = 200    
    Exit FunctionOutlook_Login_Err:    Login_Outlook = False    Exit Function
End FunctionFunction Outlook_SaveAttachment(Location As String)
    On Error GoTo Outlook_SaveAttachment_Err    
    Set myAttachments = InboxFolder.Items(EachItem).Attachments
    myAttachments.Item(EachItem).SaveAsFile Location & "\" & myAttachments.Item(EachItem).DisplayName
    Exit Function'*** Check for mail  
Nout = Locate_Mail(Inbox, "", "Registration_", "")        
Function Locate_Mail(Folder$, From$, Subject$, Body$) As Boolean
    On Error GoTo Locate_Mail_Err        
    Set InboxFolder = theNameSpace.GetDefaultFolder(Folder$)          
    For Each MailItem In InboxFolder.Items
        If InStr(1, MailItem.Subject, Subject$, vbTextCompare) Then
            EachItem = EachItem + 1            x = (InboxFolder.Items.Count)
            'Form1.List1.AddItem "SenderName :" & InboxFolder.Items(EachItem).SenderName
            'Form1.List1.AddItem "ReceivedTime :" & InboxFolder.Items(EachItem).ReceivedTime
            'Form1.List1.AddItem "SentOn :" & InboxFolder.Items(EachItem).SentOn
            'Form1.List1.AddItem "To:" & InboxFolder.Items(EachItem).To
            'Form1.List1.AddItem "Subject : " & InboxFolder.Items(EachItem).Subject
            'Form1.List1.AddItem "UnRead : " & InboxFolder.Items(EachItem).UnRead
            'Form1.List1.AddItem "UnRead : " & InboxFolder.Items(EachItem).Attachment
            'Set myAttachments = InboxFolder.Items(EachItem).Attachments
            'myAttachments.Item(1).SaveAsFile "C:\My Documents\" & myAttachments.Item(1).DisplayName
        End If            Next            If EachItem = 0 Then
        '*** If no mail item found then continue looking
        MAILBOX_STATE = 200        Exit Function    Else
        '*** If mail found set state        MAILBOX_STATE = 250        
    End If            Exit FunctionLocate_Mail_Err:Locate_Mail = False
Exit FunctionEnd Function        Function Outlook_SendMail(Letter As String)
    On Error GoTo Outlook_SendMail_Err    Dim Msg As String    Dim theMailItem
        Select Case Letter        Case "Auto_OneTel"            Msg = "Andrew, "
    Msg = Msg & Chr$(13) & "Confirming receipt of " & InboxFolder.Items(1).Attachments.Item(1).DisplayName
    Msg = Msg & "  received on " & Outlook_Get_Weekday & " " & InboxFolder.Items(EachItem).ReceivedTime & Chr$(13)
    Msg = Msg & "Kind Regards," & Chr$(13)
    Msg = Msg & "OneTel.Services@GlobalOne.net" & Chr$(13)
    Msg = Msg & "<< This is a system generated message >>"    Debug.Print Msg
        Set theMailItem = theApp.CreateItem(olMailItem)    With theMailItem
        .Subject = "Confirmation File- " & InboxFolder.Items(EachItem).Attachments.Item(1).DisplayName
        .Body = Msg        .Recipients.Add "malcolm.wilson@globalone.net"
        .Recipients.Add "wirereg@one.net.au"
        .Recipients.Add "kevinr@one.net.au"        .Send    End With    DoEvents
    Exit Function'*** Move mail to folder
Function MoveMail_To_Folder(Folder As String)
Set mydestfolder = InboxFolder.Folders(Folder)
Set myItem = InboxFolder.Items(EachItem)myItem.Move mydestfolderEnd Function
0
 
LVL 2

Expert Comment

by:cedricd
ID: 1447890
Sorry for the presentation of my reply but i had a little problem
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question