[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Moving a mail message from inbox to a custom folder

Posted on 1998-12-02
4
Medium Priority
?
167 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
  • 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

830 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