+ Reply to Thread
Results 1 to 6 of 6

Sending personalised emails from excel using VBA

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Sending personalised emails from excel using VBA

    Hi There

    I am looking for some help converting a VBS code to VBA (excel macro).

    I created a VBS which has a few functions:

    1. Create a HTML .msg file which contains a unique URL and image (downloaded from a website) based on the data entered into the first Input box. This email is then saved to a network location using the date from the Input as the file name (location of the file is irrelevant)

    2. Create a secondary HTML email that uses the email address from one (additional) Input box, is addressed to the First name entered into another Input box. This email then has the first email that was created attached to it.

    Code below:

    Please Login or Register  to view this content.

    This VBS works great for one by one creation - However now I have the need to send this custom email with the other custom email attached, too about 4,000 members.

    I have an excel workbook that contains all 4,000 contacts, and all the data that I would use for creation:

    A - Member ID
    B - First Name
    C - Last Name
    D - Email
    F - URL (URL is a concatenation of the URL & Member ID which is the link to the unique image)

    What I need is a vba macro that will do everything my vbs does, but for each record in my work book.

    Can anybody help?

    Thank You
    Simon
    Last edited by simon1985; 11-27-2012 at 01:09 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: VBS to VBA Help

    Please provide a sample workbook with some typical data.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    11-26-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBS to VBA Help

    Thank you for your response.

    Example.xls

    Attached is an example of the workbook and how the data will appear.

    Thank You
    Simon

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Sending personalised emails from excel using VBA

    Hi Simon

    This isn't quite right but the principle is demonstrated here. You can't have such long lines in VBA code so I have created a "body" string and then used that. However, the first saved email isn't structured properly for some reason so you only get the second half of it. That aside, it builds and saves the first email, builds the second email and attaches the first email ( I didn't have a second attachment) and displays each one for review, edit and send.

    If/when you get the structure of the body of the first email sorted, I'd appreciate seeing it ... I'm not big on HTML so I don't really know where to start and it's probably not really worth me spending time on it if you can fix it quickly.

    So, the code is going to look something like this:

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    11-26-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Thumbs up Re: Sending personalised emails from excel using VBA

    Hi Trevor

    My sincerest thanks for this! It works a treat.

    I have removed the sBodys and modified the .htmlbody

    Please Login or Register  to view this content.
    This is my final code (still have to modify the paths though).

    Again, thank you very much for this!

    Regards,
    Simon

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Sending personalised emails from excel using VBA

    You're very welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Last edited by TMS; 11-27-2012 at 09:38 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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