+ Reply to Thread
Results 1 to 2 of 2

Send email by using macro to specific customer

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Send email by using macro to specific customer

    Hello

    I have a code that help you send an email to customer. However, the code sets as default customer. Do you know how to change the code so that I can type manually customer email address when the command pops up. Moreover, the code is to send the entire workbook, how can we only send the active sheet or specific sheet that we want.

    Sub cmdEmailSheet_Click()

    Dim txtMsg, txtStyle, txtTitle, Response
    txtMsg = "Are you sure you want to e-mail the active sheet to Tan?" ' Define message.
    txtStyle = vbYesNo + vbQuestion + vbDefaultButton2 ' Define buttons.
    txtTitle = "Confirm E-mail" ' Define title.
    Response = MsgBox(txtMsg, txtStyle, txtTitle)
    If Response = vbYes Then ' User chose Yes.
    ActiveWorkbook.SendMail Recipients:="allannguyen@yahoo.com"
    txtMsg = "E-mail composed and sent to the Outbox." ' Define message.
    txtStyle = vbInformation ' Define buttons.
    txtTitle = "E-mail Sent" ' Define title.
    Response = MsgBox(txtMsg, txtStyle, txtTitle)
    End If
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Send email by using macro to specific customer

    didn't i already answer this one, i think you had two posts of the same thing, also remeber to mark solved if your question has been answered

    at the top of the thread click thread tools and select mark thread as solved!

    Sub cmdEmailSheet_Click()
    
    Dim txtMsg, txtStyle, txtTitle, Response
    txtMsg = "Are you sure you want to e-mail the active sheet to Tan?" ' Define message.
    txtStyle = vbYesNo + vbQuestion + vbDefaultButton2 ' Define buttons.
    txtTitle = "Confirm E-mail" ' Define title.
    Response = MsgBox(txtMsg, txtStyle, txtTitle)
    If Response = vbYes Then ' User chose Yes.
    
    '''''''''''''''''''''''add the line below to ask you to input the recipient's email address
    rec = InputBox("input recipient")
    
    ActiveWorkbook.SendMail Recipients:=rec
    txtMsg = "E-mail composed and sent to the Outbox." ' Define message.
    txtStyle = vbInformation ' Define buttons.
    txtTitle = "E-mail Sent" ' Define title.
    Response = MsgBox(txtMsg, txtStyle, txtTitle)
    End If
    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