+ Reply to Thread
Results 1 to 18 of 18

Macro to generate an email with cell contents in it...

  1. #1
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Macro to generate an email with cell contents in it...

    Hey helpful folks !

    I have a need to use excel to create roughly 200 emails, with each one containing the contents (in plain text) of unique cells in excel.

    See the attachments. The wb shows a few rows of an example dataset.
    In column I need to go the macro initiating buttons.

    The macro should create a new email to the address in column H.

    Each row is unique and therefore in the corresponding text file attached, the cell contents will need to be that of the corresponding row used. So the initiating macro in cell I4 for example, must use information from that row.

    I found this:

    http://www.rondebruin.nl/win/s1/outlook/amail4.htm

    However it was talking about inserting the cells as a worksheet and not as just the contents as plain text. Trouble is, the recipients of the emails do not necessarily have excel.

    That's about it really.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    try using this section instead
    http://www.rondebruin.nl/win/s1/outlook/bmail2.htm

    most is pretty straight forward except for your signature bit
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    see attached file which has been modified slightly
    Please Login or Register  to view this content.
    modified it to your worksheet
    basis of the email body is a worksheet as instead of writing new email from scratch every time

    it takes two sections
    rng and rng2
    top bit then signature then bottom bit
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    Wow that's fantastic ! I will give it a try shortly.

    Muchas Gracias ;-)
    Last edited by willm; 07-11-2016 at 01:15 AM.

  5. #5
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    There is some sort of issue when opening the spreadsheet you created.

    I am opening it with Microsoft office professional plus 2010 on a virtualised windows 7 installation.

    I have set all the trust centre settings to allow via / macros / activeX stuff.

    When I try to open the file, it errors out saying it cannot open it without removing something first. Then it appears to remove all the code.

    See attached screenshots. Thinking it could be a version problem? The finished file will actually be run on office 2007 I think.

    Thanks in advance.
    Attached Images Attached Images

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    Please Login or Register  to view this content.
    take this section out and try again

  7. #7
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    I can't open it to take the section out :-(

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    the code should work in either 2007 or 2010..in fact 2000 to 2016

    the fact you cant even open it probably means something else is not working

    you're not on a mac are you?
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    Will try the edited one -thanks.

  10. #10
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    Hmm that's weird, it still won't open, same problem.

  11. #11
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    here is just the file without the code
    add the code in yourself thru VBE environment
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    Quote Originally Posted by humdingaling View Post
    here is just the file without the code
    add the code in yourself thru VBE environment
    Hi, okay it works okay on a physical windows machine.

    One last request !

    Say I wanted to build a button at the end of each row that did what it currently does, but just for that row it sent the mail?
    And also, the macro as it is spawns all the emails okay, however it does not send them, would be good if the button just sent the email, since there is no reason for me to sanity check it.

    Thanks so much for your help with this already, your assistance is invaluable ! ;-)

  13. #13
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    Say I wanted to build a button at the end of each row that did what it currently does, but just for that row it sent the mail?
    you can do that...but how many buttons are you talking about?
    just feel it will become slow over time when you have 100's of buttons

    you can get the row of the button via this code application.caller

    below is example.....insert a button and add this to the code
    press the button and it should tell you the row it is is
    Please Login or Register  to view this content.
    as mentioned in code
    it takes the topleft point of the button as anchor to return the row



    the macro as it is spawns all the emails okay, however it does not send them
    change .display to be .send

    Please Login or Register  to view this content.
    i always use display instead of send while debugging/testing
    until you are completely content of the output then use .send

  14. #14
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    heres a link on how to add the button and add the code at the same time

    http://stackoverflow.com/questions/4...heet-cell-data

  15. #15
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    Thanks humdingaling. I'd buy you a pint if you weren't so far away.

  16. #16
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    ONE last thing - when the email gets crafted, specifically this:

    Subject = "This is the Subject line" ' replace with whatever you want as subject line

    What if i wanted to insert "Tape changes for X country", where X is the text content of a cell in the worksheet?

  17. #17
    Registered User
    Join Date
    08-31-2011
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Macro to generate an email with cell contents in it...

    Quote Originally Posted by willm View Post
    ONE last thing - when the email gets crafted, specifically this:

    Subject = "This is the Subject line" ' replace with whatever you want as subject line

    What if i wanted to insert "Tape changes for X country", where X is the text content of a cell in the worksheet?

    ignore that i figured it out :-)

  18. #18
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to generate an email with cell contents in it...

    glad everything worked out in the end


    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Replies: 23
    Last Post: 08-04-2015, 03:47 PM
  2. Comparing contents in 2 columns of pivote tavle & if contents found same then generate
    By Parag Chincholikar in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-21-2014, 05:40 AM
  3. Macro to generate email when number reached?
    By meadsie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2014, 03:10 AM
  4. Generate hyperlink based on cell contents, end when condition met
    By PompadourJay in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-10-2014, 03:27 PM
  5. macro to email cell contents from an excel worksheet
    By lrm75uk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2011, 04:52 PM
  6. Generate Email through a macro
    By SunyIT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2008, 12:32 PM
  7. Macro to email contents of cell line by line
    By drew_f_taylor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2007, 06:48 AM

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