+ Reply to Thread
Results 1 to 2 of 2

VBA to send a selection on a sheet in the body of email

Hybrid View

JonSalmon87 VBA to send a selection on a... 08-31-2018, 08:02 AM
davesexcel Re: VBA to send a selection... 08-31-2018, 08:05 AM
  1. #1
    Registered User
    Join Date
    08-28-2018
    Location
    Hampshire, England
    MS-Off Ver
    MS 365
    Posts
    12

    VBA to send a selection on a sheet in the body of email

    Hi, Im trying to make an email vba with an activeX button to send a table of information.

    I have attached a workbook with the example of what im trying to to for reference.

    I am trying to send an email which will in the body of the email do the following:

    show cell M17
    then 1 line down show range m13:n14
    then 2 lines down show the range H4:k33.

    As you can see with the coding so far, i am typing in cell by cell, but there must be a more efficient way of coding this?



    Any help would be greatly appreciated, thank you in advance!

    Kind Regards

    Jon







    My code so far looks like this:



    Private Sub CommandButton1_Click()
    Dim mainWB As Workbook
    Dim SendID
    Dim CCID
    Dim Subject
    Dim Body
    
    Set otlApp = CreateObject("Outlook.Application")
    Set olMail = otlApp.CreateItem(olMailItem)
    Set mainWB = ActiveWorkbook
    
    SendID = mainWB.Sheets("TRADE").Range("N6").Value
    CCID = mainWB.Sheets("TRADE").Range("N7").Value
    Subject = "ORDER CONFIRM" & mainWB.Sheets("TRADE").Range("N11").Value
    Body = mainWB.Sheets("TRADE").Range("M17").Value & vbNewLine & vbNewLine & mainWB.Sheets("TRADE").Range("H4").Value & mainWB.Sheets("TRADE").Range("I4").Value & mainWB.Sheets("TRADE").Range("J4").Value & mainWB.Sheets("TRADE").Range("K4").Value
    
    
    With olMail
        .To = SendID
        If CCID <> "" Then
          .CC = CCID
        End If
        .Subject = Subject
        .Body = Body
        .Send
    
    End With
    MsgBox ("trade confirm has been sent to " & SendID)
    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: VBA to send a selection on a sheet in the body of email

    There is no attachment.
    What do you mean by..."As you can see with the coding so far, i am typing in cell by cell, but there must be a more efficient way of coding this?"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to send a selection on a sheet in the body of email
    By JonSalmon87 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-31-2018, 03:44 PM
  2. [SOLVED] Need to send sheet 1 in the body of the email and sheet 2 as an attachment
    By aliciaward1001 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-28-2018, 11:36 AM
  3. How to send email from excel using VBA with Cell Range (Including Images) as Email Body
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2014, 05:06 AM
  4. Send New Email W/ Body of Received Email, Then Delete Sent Email
    By edneal2 in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 07-01-2013, 12:45 AM
  5. [SOLVED] Send Email 1 sheet as attachment and other sheet as body of emial.
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-19-2013, 02:57 AM
  6. Replies: 6
    Last Post: 12-02-2011, 02:14 PM
  7. send excel work sheet as the body of email.
    By c_worc in forum Excel General
    Replies: 1
    Last Post: 11-11-2005, 12:20 PM

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