moving attached email to inbox RRS feed

  • Question

  • Hello,

    Can anybody help me with this macro ?

    I have tho following problem.
    I want to write a makro that moves an attached mail to the inbox.
    It works so far. But the mail then is in the layout modus, like I wanted to sent it. I want in in the read mode like an email that arrived.

    I wrote the following( with help of an existing acript):

    Public Sub RemoveAttachments(item As MailItem)

    Dim ns As NameSpace
    Dim Inbox As MAPIFolder
    Dim Atmt As Attachment
    Dim FileName As String
    Dim itemnew As Object
    Dim foundemail As Boolean
    foundemail = False

    Set ns = GetNamespace("MAPI")
    Set Inbox = ns.GetDefaultFolder(olFolderInbox)

    For Each Atmt In item.Attachments

    If Right(Atmt.FileName, 3) = "msg" Then
    foundemail = True
    FileName = "c:\temp\"

    Atmt.SaveAsFile FileName & Atmt.FileName

    Set itemnew = Outlook.Application.CreateItemFromTemplate(FileName & Atmt.FileName)
    itemnew.UnRead = True
    itemnew.Move Inbox

    End If

    Next Atmt

    item.Move ns.GetDefaultFolder(olFolderDeletedItems)

    End Sub


    Thanks a lot

    Saturday, May 1, 2010 12:55 PM