+ Reply to Thread
Results 1 to 10 of 10

Auto E-Mail to preselected list.

  1. #1
    Forum Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Auto E-Mail to preselected list.

    This is for a mailing of the standings for the NCAA tournament. I have done a search and found the following link,
    HTML Code: 
    . and have applied this to my sheet but I am at a loss as to how to pick up each address from column "D" on the E-Mail sheet.

    Thanks

    JIm O
    Attached Files Attached Files
    Last edited by Jogier505; 03-16-2010 at 03:40 PM.

  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: Auto E-Mail to preselected list.

    Further in that site is this page, which shows how to cycle through a column and test for the @ symbol to determine if an email address is there...

    http://www.rondebruin.nl/mail/folder1/mail5.htm
    _________________
    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 Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Re: Auto E-Mail to preselected list.

    With my very limited knowledge of VBA I am missing something. I have applied the code to module 1 in the workbook but I am not sure where to refference the sheet "E-Mail".


    Please Login or Register  to view this content.

    Thanks

    Jim O

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Auto E-Mail to preselected list.

    Hello Jim,

    Here is a simplified version of the macro. This macro has been added to the attached workbook and to the button on the "Standings" worksheet.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    Re: Auto E-Mail to preselected list.

    Leith, great stuff. I need to spend more time with the SendMail stuff.

    One thought, you should be able to fill your Addresses array directly without looping or even redimming.:
    Please Login or Register  to view this content.

    The "I" variable needed to be declared, but in this situation you won't need it at all.

    One other thought, you might be able to fill in the RNG all in one step as well, with:
    Please Login or Register  to view this content.

    What do you think? We may only be talking milliseconds, but what the hey!

    My two cents...

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Auto E-Mail to preselected list.

    Hello Jerry,

    Thanks for the input. Let me explain the logic behind my decisions. VBA will generally and automatically adjust a standard Array, zero based, to a Range which is one based and always 2-D and vice versa. I chose to use the loop to ensure the string Array required by the SendMail function is a always a zero based array. SendMail function invokes the default email client and may not convert the 1 based array correctly to a zero based array. The macro would then miss the first email address in the list. If there is only email being sent and there is no address then the email client will throw an error.

    The code structure I use for setting the Rng object variable will not error if the cells are empty. It simply defaults to the first cell in the range. The SpecialCells property will. Also, you can not check this property first to verify there are no empty cells. You have to trap the error using an On Error Resume or On Error Goto statement. Personally, I like to avoid runtime errors whenever possible.

  7. #7
    Forum Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Re: Auto E-Mail to preselected list.

    I am still having problems getting the code to work. I keep getting a run time error 1004.
    When I click the send button on the sheet the temp file is created and a screen comes up with the subject line but no addresses. If I click the send button on the new screen I am asked weather I want to end or debug. See attached file.


    Thanks, Jim O
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Re: Auto E-Mail to preselected list.

    Bump.

    Any thoughts?


    Jim O

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Auto E-Mail to preselected list.

    Hello Jim,

    Try using valid email addresses on the email sheet. Here is the error I got when I ran the code. Look familiar?
    Run-time error '1004'

    Unknown recipient found in the recipient list. Use a valid name and try again.

  10. #10
    Forum Contributor
    Join Date
    09-09-2009
    Location
    Columbus. Ohio
    MS-Off Ver
    Excel 2000
    Posts
    199

    Re: Auto E-Mail to preselected list.

    Leith,

    That appears to be the problem. Sorry to be such a bother but with my very limited VBA knowledge I was sure it was something I had got wrong. Of course this presents a whole new range of issues but they are all on my end (making sure all addresses are correct).

    Thanks to you and JBeaucaire for your time and effort with us beginners. I will mark this thread as SOLVED.


    Jim O

+ Reply to Thread

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