• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

Outlook send selected email as attachment and delete

I'm looking for a way to automaticaly send email items in my inbox as an attachment to a fixed address. Also I 'd like to creat a button on my toolbar and tie this action to it.

Example: I select a few items in my inbox and then click the toolbar button. Those selected items are then inserted in to a new email. That new email is sent to a somthing@somthing.com. After the email is sent, the selected emails are deleted.

I'm using Outlook 2010
Erik Curtis
Erik Curtis
1 Solution
Naser GabajCommented:

I never try it before, but I believe this tool can do the job for you


Good luck
copy code below into a macro

This page will show you how to add a button to the toolbar


Private Declare Function GetTempPath Lib "kernel32" _
         Alias "GetTempPathA" (ByVal nBufferLength As Long, _
         ByVal lpBuffer As String) As Long
      Private Declare Function GetTempFileName Lib "kernel32" _
         Alias "GetTempFileNameA" (ByVal lpszPath As String, _
         ByVal lpPrefixString As String, ByVal wUnique As Long, _
         ByVal lpTempFileName As String) As Long
      Private Function CreateTempFile(sPrefix As String) As String
         Dim sTmpPath As String * 512
         Dim sTmpName As String * 576
         Dim nRet As Long
         nRet = GetTempPath(512, sTmpPath)
         If (nRet > 0 And nRet < 512) Then
            nRet = GetTempFileName(sTmpPath, sPrefix, 0, sTmpName)
            If nRet <> 0 Then
               CreateTempFile = Left$(sTmpName, _
                  InStr(sTmpName, vbNullChar) - 1)
            End If
         End If
      End Function
Sub GetSelected()
Dim messages()
Dim mail As MailItem
Dim tmpPath
Dim currentMail As MailItem
If Not IsEmpty(ActiveExplorer.Selection) Then
    For Each CurrentItem In ActiveExplorer.Selection
        If CurrentItem.Class = olMail Then
            If mail Is Nothing Then Set mail = Application.CreateItem(olMailItem)
                counter = counter + 1
                Set currentMail = CurrentItem
                tmpPath = CreateTempFile("OL")
                currentMail.SaveAs tmpPath, olMSG
                mail.Attachments.Add tmpPath
            End If
End If
mail.BodyFormat = olFormatHTML
mail.Subject = "Emails forwarded"
mail.Body = "emails attached"
mail.To = "yourEmail@ou.com"
msgbox "Finished"
end sub

Open in new window

Erik CurtisAuthor Commented:
This works just as it should!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now