Solved

Moving a mail message from inbox to a custom folder

Posted on 1998-12-02
4
154 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 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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