Consulting

Results 1 to 3 of 3

Thread: Resending Macro

  1. #1
    VBAX Regular Rishek's Avatar
    Joined
    May 2017
    Posts
    75
    Location

    Resending Macro

    Fully aware that I am trying to do something a bit idiotic, but here's what I'm trying to achieve: I want a button that automatically sends the current item to preset addresses and then resends it twice to further addresses. Here's what I've got:

    Sub MAILBLAST()
    Call Resend
    Call Resend2
    Call Resend3
    End Sub
    Sub Resend()
    Dim rMsg As MailItem, oInspector As Inspector
    Set oInspector = Application.ActiveInspector
    If oInspector Is Nothing Then
        MsgBox "No active inspector"
    Else
        Set rMsg = oInspector.CurrentItem
        rMsg.To = "myemail@email.com"
        rMsg.To = "Address that can't be Bcc'd (Printer)"
        rMsg.BCC = "Distribution 1"
        rMsg.Send
    End If
    End Sub
    Sub Resend2()
    Dim rMsg As MailItem, oInspector As Inspector
    Set oInspector = Application.ActiveInspector
    If oInspector Is Nothing Then
        MsgBox "No active inspector"
    Else
        Set rMsg = oInspector.CurrentItem
        rMsg.To = ""myemail@email.com"
        rMsg.BCC = "Distribution 2"
        rMsg.Send
    End If
    End Sub
    Sub Resend3()
    Dim rMsg As MailItem, oInspector As Inspector
    Set oInspector = Application.ActiveInspector
    If oInspector Is Nothing Then
        MsgBox "No active inspector"
    Else
        Set rMsg = oInspector.CurrentItem
        rMsg.To = "myemail@email.com"
        rMsg.BCC = "Distribution 3"
        rMsg.Send
    End If
    End Sub
    The obvious difficulty is that once the first Resend() runs, the message is sent and I lose the .CurrentItem. How can I circumvent this?

    Many thanks to Stefano Balzarotti for the original code.

  2. #2
    It seems somewhat bizarre, however

    Option Explicit
    
    Sub MAILBLAST()
    Dim rMsg As MailItem, oInspector As Inspector
        Set oInspector = Application.ActiveInspector
        If oInspector Is Nothing Then
            MsgBox "No active inspector"
            GoTo lbl_Exit
        Else
            Set rMsg = oInspector.currentItem
            Resend rMsg
            Resend2 rMsg
            Resend3 rMsg
        End If
        rMsg.Close olDiscard 'optional
    lbl_Exit:
        Exit Sub
    End Sub
    
    Sub Resend(rMsg As MailItem)
        Dim olItem As MailItem
        Set olItem = rMsg.Copy
        olitem.To = "myemail@email.com"
        'olItem.To = "Address that can't be Bcc'd (Printer)"
        olItem.BCC = "Distribution 1"
        olItem.Send
    End Sub
    Sub Resend2(rMsg As MailItem)
        Dim olItem As MailItem
        Set olItem = rMsg.Copy
        olItem.To = ""myemail@email.com"
        olItem.BCC = "Distribution 2"
        olItem.Send
    End Sub
    Sub Resend3(rMsg As MailItem)
        Dim olItem As MailItem
        Set olItem = rMsg.Copy
        olitem.To = "myemail@email.com"
        olItem.BCC = "Distribution 3"
        olItem.Send
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Regular Rishek's Avatar
    Joined
    May 2017
    Posts
    75
    Location
    Works like a charm. As dumb as it sounds, this integrates quite well into the work flow. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •