+ Reply to Thread
Results 1 to 4 of 4

Send email via Excel button.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-02-2007
    Location
    Charlotte, NC
    Posts
    31

    Send email via Excel button.

    I have an Excel spreadsheet/form that once completed by user, they click a button to send an email to a help desk, with the form.

    I would also want the person who is filling out the form to receive an email.

    How can I add to the below code??
    >>>>>>>>>>>>>>>>>>>>>>>
    Sub Macro3()
    
        ActiveWorkbook.HasRoutingSlip = True
    
          With ActiveWorkbook.RoutingSlip
            .Recipients = "[email protected]"
            .Subject = "Routing: New Owner Form"
            .Message = _
            "Your Request has been received and will be added as a New Owner!"
            .Delivery = xlAllAtOnce
            .ReturnWhenDone = False
            .TrackStatus = False
          End With
    
        ActiveWorkbook.Route
        ActiveWindow.SmallScroll Down:=-9
        Range("E7:M7").Select
    
        MsgBox Prompt:="Email has been sent to Portfolio User Support" & myVar, _
        Title:="Confirmation", _
        Buttons:=vbOKCancel
      
    End Sub
    Last edited by Leith Ross; 11-07-2007 at 12:53 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why would you want the sender to receive an email? You notify that it has been sent with the messagebox.

    Also, you use the variable MyVar without declaring it or giving it a value:
        Const MyVar As String = "[email protected]"
    
        ActiveWorkbook.HasRoutingSlip = True
    
        With ActiveWorkbook.RoutingSlip
            .Recipients = MyVar
            .Subject = "Routing: New Owner Form"
            .Message = _
            "Your Request has been received and will be added as a New Owner!"
            .Delivery = xlAllAtOnce
            .ReturnWhenDone = False
            .TrackStatus = False
        End With
    
        ActiveWorkbook.Route
        ActiveWindow.SmallScroll Down:=-9
        Range("E7:M7").Select
    
        MsgBox Prompt:="Email has been sent to Portfolio User Support" & MyVar, _
               Title:="Confirmation", _
               Buttons:=vbOKCancel
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Novice_704,

    The recipients are added as an Array (see the code) with the names separated by commas. I have run the macro with only names that were in my address book. I haven't tested it using an email address in the Recipients.
    Sub Macro3()
     Dim olApp As Outlook.Application
     Dim olNamespace As Outlook.Namespace
     
        Set olApp = CreateObject("Outlook.Application")
        Set olNS = olApp.GetNamespace("MAPI")
        SendersName = olNS.CurrentUser
        
          ThisWorkbook.HasRoutingSlip = True
    
            With ThisWorkbook.RoutingSlip
              .Delivery = xlAllAtOnce
              .Recipients = Array("[email protected]", SendersName)
              .Subject = "Routing: New Owner Form"
              .Message = "Your Request has been received and will be added as a New Owner!"
             .ReturnWhenDone = False
             .TrackStatus = False        
          End With
            
         ThisWorkbook.Route
         
         MsgBox Prompt:="Email has been sent to Portfolio User Support" & MyVar, _
               Title:="Confirmation", _
               Buttons:=vbOKCancel
         Range("E7:M7").Select
    
       olApp.Quit
       Set olApp = Nothing
       Set olNS = Nothing
    
    End Sub
    If you have any problems with this code, please let me know.

    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    06-05-2008
    Posts
    84
    All I am working on something similar.

    I have a sheet that needs to be "approved" by multiple people.

    What I need is this to be sent to one "approver" at a time.


    Approvers name (recipient) are in cells B29, B31, B33 and B35. And sometimes not all 4 will be populated.


    So I would create the sheet put the "recipients" in and hit the Button "ROUTE"

    Then it will go to the firts person. There are drop downs that they will have to mark "approved" then hit a "ROUTE" button to send to the next person.


    This macro goes to the first person and then sends it back to them.


    Please help.

    Private Sub CommandButton2_Click()
        ActiveWorkbook.HasRoutingSlip = True
        With ActiveWorkbook.RoutingSlip
            .Recipients = Range("B29", "B31")
            .Subject = "Plant" & " " & Range("B12") & " " & "WO#" & " " & Range("WO")
            .Message = "Please review this add-on test"
            .Delivery = xlOneAfterAnother
            .ReturnWhenDone = True
            .TrackStatus = True
        End With
        ActiveWorkbook.Route
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1