Results 1 to 6 of 6

Email code that has different cell values for message body

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-27-2014
    Posts
    141

    Email code that has different cell values for message body

    Hi All,

    Wonder if it's possible? I have code that generates multiple emails based on a table, but I am trying to modify the code so that the message body shows the contents of particular column on different lines for each associated email address

    So the message body would look like the below

    Dan Hardy (Column B),

    Line of customisable text within code

    Sunday 22 Nov 2015 - OFF (Column D)
    Monday 23 Nov 2015 - IN (Column E)
    Tuesday 24 Nov 2015 - IN (Column F)
    Wednesday 25 Nov 2015 - IN (Column G)
    Thursday 26 Nov 2015 - IN (Column H)
    Friday 27 Nov 2015 - IN (Column I)
    Saturday 28 Nov 2015 - IN (Column J)

    Line of customisable text within code

    the code I have is below

    Private Sub CommandButton1_Click()
        On Error Resume Next
        Dim objOutlook As Object
        Dim objMail As Object
        Dim rngEntry As Range
        Dim rngEntries As Range
        Dim sMsgBody As String
    
        Set objOutlook = CreateObject("Outlook.Application")
        Set rngEntries = ActiveSheet.Range("C3:C102")
        
        For Each rngEntry In rngEntries
    
    If rngEntry.Value = "" Then GoTo Skip
    If rngEntry.Value = "0" Then GoTo Skip
    
            Set objMail = objOutlook.CreateItem(0)
            With objMail
                .To = rngEntry.Value
                .Subject = "Confirmed Working Pattern for NEXT WEEK"
                sMsgBody = "Hi," & vbCr & vbCr
                sMsgBody = sMsgBody & "Please " & vbCr & vbCr
                sMsgBody = sMsgBody & "Remember " & vbCr & vbCr
                sMsgBody = sMsgBody & "Notes " & vbCr & vbCr
                .Body = sMsgBody
                .display
            End With
    
    Skip:
        Next rngEntry
        
        Set objOutlook = Nothing
        Set objMail = Nothing
        Set rngEntry = Nothing
        Set rngEntries = Nothing
    I have attached the file as well if it makes it easier to understand, it may well be a simple solution but the ones that I am trying are just creating blank emails

    Thanks in Advance

    Danny
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] how to link textbox message as email body using excel VBA code
    By yogi_himalayan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-01-2014, 08:40 PM
  2. Email Message body with reference to cell using VBA coding
    By MakkyD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-23-2013, 03:52 AM
  3. Qutlook email with signature using body message from cell values
    By gmc2k2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2013, 10:11 AM
  4. email excel spreadsheet as body of message, not as attachment
    By Email Spreadsheet as Body of Email Msg. in forum Excel General
    Replies: 6
    Last Post: 06-18-2012, 01:01 PM
  5. Pasting Range from worksheet into Body of Email Message
    By AZGryphon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-10-2012, 06:29 PM
  6. Copy a range to the body in email message
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2008, 02:52 PM
  7. email sheet as message body with chart
    By Nicky in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2007, 07:16 AM
  8. [SOLVED] Body message - email
    By al007 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2006, 07:10 AM

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