Results 1 to 4 of 4

Spacing error with Email Macro

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    181

    Spacing error with Email Macro

    The email macro I set up didn't work when I referenced the sendto from a cell in sheet 2; I changed it to reference an email address on sheet 1 and it worked with spacing errors.

    I need to fix the spacing errors, and I need to be able to pull the email from sheet 2.


    Code referencing sheet 2:

    Sub MailSped1()
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        Dim SndTo As String
        
    With Sheets("Sheet2")  'the debugger highlights this and will not send email'
        SndTo = .Range("E7")
        
    End With
    Code for email body, which has spacing errors:

    With Sheets("Sheet1")
        strbody = "Students' points in my class" & vbNewLine & vbNewLine & _
            .Range("A41") & .Range("B41") & vbNewLine & _
            .Range("A42") & .Range("B42") & vbNewLine & _
            .Range("A43") & .Range("B43") & vbNewLine & _
            .Range("A44") & .Range("B44")
    End With
       
    'I deleted the code in between just to shorten this message'
        With OutMail
            .To = SndTo
            .CC = ""
            .BCC = ""
            .Subject = "Student 's" & "Points"
            .htmlbody = strbody
            .Send
        End With
    Just to test the email I changed the line that was having troubles to reference sheet 1, and although it sent the email; the email had spacing errors.

    Here is the email it sent:

    Subject line: Students'points

    Body Line: Students' points in my class Harley Peterson45 Ratino Sherrod35


    I want it to send like this:

    Students points in my class

    Harley Peterson 45
    Ratino Sherrod 35

    etc....
    Last edited by dsrt16; 12-20-2009 at 03:40 AM.

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