Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Thanked 0 Times in 0 Posts

    Passing data to email (2000)

    I'm using code in excel to send emails, and i'm having trouble passing the message body text into the email.

    <font color=blue>Dim sMessageBody As Worksheet </font color=blue> '/Holds the Message text. Also tried 'As Variant' and 'As Range'

    <font color=blue>sMessageBody = ThisWorkbook.Worksheets("Email") </font color=blue> ' .Range("A1:L23")

    The amount of information is variable, so it might be 8 rows, or 30 rows. If possible i would like to control the size and type of the font used as well..

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Passing data to email (2000)

    The body of an e-mail message is text, so you should declare sMessageBody as a string, not as a worksheet (or a range). You don't mention which e-mail system you are going to use, but in Outlook, the MailItem object has a property Body that can be used to specify plain text, and a property HTMLBody that can contain HTML text. You can't just assign a worksheet or range to the Body or HTMLBody property.
    If you want to include a range like A1:L23, it might be better to send the spreadsheet as attachment. That way, you wouldn't have to worry about the number of rows or columns either. Including a 12 column table with an unknown number of rows in the body of an e-mail is probably not very practicable.

Posting Permissions

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