+ Reply to Thread
Results 1 to 9 of 9

Why is my email code sending a blank email?

  1. #1
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Question Why is my email code sending a blank email?

    Hello everyone,
    I thought I had this all figured out, (thanks to Leith) but alas, I don't. I have code that creates a sheet with updated information only, which is by date and currentuser. Then it is supposed to email that sheet as and HTML in the body of the email. This is all done when a user clicks a button on the userform. Everything works as expected except the email part of the code. Instead of emailing it as HTML in the body of the email, it attaches it to the email but the email and attachment are blank. Can someone take a look at the code below and see where I have gone wrong, please?
    Please Login or Register  to view this content.
    Sorry about the lengthy code.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Why is my email code sending a blank email?

    I'm not sure you've posted the correct code. This function converts a range of cells to HTML. Perhaps there is another macro calling this function and also creating the email that isn't working?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Why is my email code sending a blank email?

    Jerry,
    Thank you for the response. I wasn't sure if I should include the other code or not, that is why I left it out. You are correct though, there is another macro calling this function, here it is......
    Please Login or Register  to view this content.
    Last edited by gmr4evr1; 06-26-2015 at 05:30 PM. Reason: Corrected typos

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Why is my email code sending a blank email?

    Ok, I've used that code before, I'm sure we all have. I don't see anything obvious wrong with that email code. Comment out this line:
    Please Login or Register  to view this content.
    ....hopefully a meaningful error will occur and your can DEBUG to see which line of code is failing you.

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Why is my email code sending a blank email?

    Ok, it errors out at this line...
    Please Login or Register  to view this content.
    As well as this line....
    Please Login or Register  to view this content.
    When I remove the On Error Resume Next lines individually

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Why is my email code sending a blank email?

    You're failing on the object name, the name of the sheet doesn't match what you're feeding in in some way. What was the error? Subscript out of range? That means a named object is is incorrect.

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Why is my email code sending a blank email?

    My bad, I can't believe I didn't include the error I was getting. I will update with the error this morning.

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Why is my email code sending a blank email?

    Jerry,
    Ok, I figured out the first part (I think). I removed the "On error resume next" as you suggested. Then I noticed there was an "If error = 9" so I removed that as well as it was just "skipping" that part anyway and creating and naming the sheet like I wanted. Now I get a "Run-time error 438: Object doesn't support this property or method" at this line..
    Please Login or Register  to view this content.
    I will play around with it some more to see if I can get it figured out. If I don't post anything, I haven't figured it out and could still use your help.

    Edit* Ok, I figured something else out. The first bit of code I posted is creating a temp file and the line it errors out on is "getting" that temp file (in the original code before I started changing things around). The problem is that the temp file has nothing in it, the information I am trying to grab is actually put into a newly created worksheet (End of shift Report) that is in the same workbook that the code and is in.
    My question is, what does the
    Please Login or Register  to view this content.
    need to be in order for me to pull the information from the newly created sheet in the active workbook?
    Last edited by gmr4evr1; 06-28-2015 at 04:28 PM. Reason: Added info

  9. #9
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Why is my email code sending a blank email?

    Solved per this thread
    http://www.excelforum.com/excel-prog...-with-vba.html
    Thank you Gregor Y

+ 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. olMail - Email Attachment Variable. Sending Email through Excel
    By ShakJames in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2014, 07:55 AM
  2. olMail - Email Attachment Variable. Sending Email through Excel
    By ShakJames in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2014, 07:41 AM
  3. Sending Email from VBA - selecting correct email address issue
    By Rachieo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2014, 03:51 PM
  4. [SOLVED] sending email with specific range as email body vba modification
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2014, 11:24 AM
  5. automation/macro for sending email to multiple email address
    By saurabhlotankar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2013, 12:13 PM

Tags for this Thread

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