none
How to send opened email as attachment to particular email id RRS feed

  • Question

  • HI Team\all,

    So many spam email getting to users, user send email directly to IT but no one give that email in attachment. Meanwhile I want to create a macro with button so they can easily send with button.


    Thanks & Regards, Amol . Amol Dhaygude

    Thursday, March 1, 2018 8:18 AM

Answers

  • The following will send a selected message as an attachment in a new message to the named recipient.

    Sub SendAsAttachment()
    Dim olMsg As MailItem
    Dim olItem As MailItem
    Dim olInsp As Outlook.Inspector
    Dim wdDoc As Object
    Dim oRng As Object
        On Error Resume Next
        Set olMsg = ActiveExplorer.Selection.Item(1)
        Set olItem = CreateItem(olMailItem)
        With olItem
            .Attachments.Add olMsg
            .To = "someone@somewhere.com"
            .Subject = "The message subject"
            .BodyFormat = olFormatHTML
            Set olInsp = .GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oRng = wdDoc.Range(0, 0)
            oRng.Text = "This is the body of the message" & vbCr & "Another line."
            .Display
            .Send
        End With
    lbl_Exit:
        Set olMsg = Nothing
        Set olItem = Nothing
        Set olInsp = Nothing
        Set wdDoc = Nothing
        Set oRng = Nothing
        Exit Sub
    End Sub
    
    


    Graham Mayor - Word MVP
    www.gmayor.com

    • Marked as answer by amoltofi Thursday, March 1, 2018 10:46 AM
    Thursday, March 1, 2018 9:01 AM

All replies

  • The following will send a selected message as an attachment in a new message to the named recipient.

    Sub SendAsAttachment()
    Dim olMsg As MailItem
    Dim olItem As MailItem
    Dim olInsp As Outlook.Inspector
    Dim wdDoc As Object
    Dim oRng As Object
        On Error Resume Next
        Set olMsg = ActiveExplorer.Selection.Item(1)
        Set olItem = CreateItem(olMailItem)
        With olItem
            .Attachments.Add olMsg
            .To = "someone@somewhere.com"
            .Subject = "The message subject"
            .BodyFormat = olFormatHTML
            Set olInsp = .GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oRng = wdDoc.Range(0, 0)
            oRng.Text = "This is the body of the message" & vbCr & "Another line."
            .Display
            .Send
        End With
    lbl_Exit:
        Set olMsg = Nothing
        Set olItem = Nothing
        Set olInsp = Nothing
        Set wdDoc = Nothing
        Set oRng = Nothing
        Exit Sub
    End Sub
    
    


    Graham Mayor - Word MVP
    www.gmayor.com

    • Marked as answer by amoltofi Thursday, March 1, 2018 10:46 AM
    Thursday, March 1, 2018 9:01 AM
  • It's working ton of thanks.

    Thanks & Regards, Amol . Amol Dhaygude


    • Edited by amoltofi Thursday, March 1, 2018 10:46 AM
    Thursday, March 1, 2018 9:18 AM
  • Thanks for help. Now challenge how to spread this to all user and install like exe or addins. Please suggest simple way.

    Thanks & Regards, Amol . Amol Dhaygude

    Thursday, March 15, 2018 10:51 AM