+ Reply to Thread
Results 1 to 8 of 8

Mail Merge to Email

  1. #1
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Mail Merge to Email

    Hi,

    I started to write code for a mail merge, but it only seems to be working in the "Directory" format whereas I will need the final result in the "Email" format. In the example attachments, I will need to send out 3 emails (one per manufacturer) with the corresponding product list changing in each. For the first manufacturer, the email should look as follows (the red text is what needs to change every time the manufacturer name changes):

    "Dear Joanne,

    We will need a list of these products sent in by November 23rd, 2017.

    List of Products (Code --- Manufacturer --- Brand Name):

    123 --- ABC Food --- Gold
    345 --- ABC Food --- Orange


    Thank you in advance for your assistance on this initiative.

    Jane Doe
    (888) 876-6543"

    The code currently written in the word document seems to ignore the email signature portion ("Thank you in advance...") and it puts each product in it's own email rather than grouping them together in one email per manufacturer. It also ignores the formatting (mainly the spaces between paragraphs).

    Would anyone be able to help me edit this code in order to send out the 3 emails at once?

    Thank you in advance for your help!

    Nicole
    Attached Files Attached Files

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Email

    Directory merges cannot send their output to email. Word will have generated an error message to that effect.

    That said, you can use Word's Catalogue/Directory Mailmerge facility for this (the terminology depends on the Word version). To see how to do so with any mailmerge data source supported by Word, check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
    http://windowssecrets.com/forums/sho...merge-Tutorial
    or:
    http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip
    The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it.

    Depending on what you're trying to achieve, the field coding for this can be complex. However, since the tutorial document includes working field codes for all of its examples, most of the hard work has already been done for you - you should be able to do little more than copy/paste the relevant field codes into your own mailmerge main document, substitute/insert your own field names and adjust the formatting to get the results you desire.

    Another option would be to use a DATABASE field in a normal ‘letter’ mailmerge main document and a macro to drive the process. An example of this approach can be found at: http://answers.microsoft.com/en-us/o...1-1996c14dca5d
    Conversely, if your workbook has a separate sheet with just a single instance of each of the grouping criteria, a DATABASE field in a normal ‘letter’ mailmerge main document could be used without the need for a macro. For an example of that, see: https://answers.microsoft.com/en-us/...f-8642e46fa103

    Alternatively, you may want to try one of the Many-to-One Mail Merge add-ins, from:
    Graham Mayor at http://www.gmayor.com/ManyToOne.htm; or
    Doug Robbins at http://bit.ly/1hduSCB
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: Mail Merge to Email

    Hi Paul,

    This is very helpful, thank you! I think I am getting closer, but I am still not incredibly good at macros or mail merges so I think a bit of the code just needs to be tweaked but I am not sure what it is. Based off of your tutorial, I have created an email merge document and then a directory document with no spaces (saved to the same folder). I then ran the VBA code from the directory document, but I am getting the error "The requested member of the collection does not exist". I am assuming this has something to do with the format of the raw data in my excel file, but I am not sure.

    I then run the macro and DOES work to create the output I am looking for, but only in a separate word document and not in separate emails. Do you have any idea why the email portion of the macro isn't catching on? I have attached my newest files for reference.

    Thanks!

    Nicole

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Email

    Your 'Email Merge Main Document.docx' file contains the field coding for a normal directory merge, not just the boilerplate text and the «Data» field (plus the «Recipient» field or equivalent, if used). It's also in the .docx format, whereas the instructions specify the .doc format.

    Your 'Merge Code Test (Directory).docx‎' file also contains the field coding for a normal directory merge, not field coding like that described for an email merge. It, too is in the .docx format, but docx files cannot contain macros, which is what that document needs for the process to run.

  5. #5
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: Mail Merge to Email

    Hi,

    I have downloaded the files in your tutorial and am trying to execute the code using those instead before attempting to alter any code for my needs. However, I am still have issues. This is what I did:

    First, I edited the document "Email Merge Main Document" to Mailings --> Select Recipients and connected this to the word document titled EmailDataSource.

    I then put in your suggested code (under "Merging by catalog/Directory to E-Mail") into the Mailmerge Main document and then selected Mailings --> Select Recipients and connected this to the excel file.

    Still in this second file, I inserted a new module and pasted in the VBA code. When I run the code, I am receiving the following error: "Object Variable or With block variable not set" referring to the paragraph line of the following section of the code:

    Sub EmailMergeTableMaker(DocName As Document)
    Dim oTbl As Table, i As Integer, j As Integer, oRow As Row, oRng As Range, strTxt As String
    With DocName
    .Paragraphs(1).Range.Delete

    Any idea what I am missing?

    Thanks!

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Email

    You are quite clearly not following the instructions. Nowhere do they tell you to do this:
    I edited the document "Email Merge Main Document" to Mailings --> Select Recipients and connected this to the word document titled EmailDataSource
    Indeed, had you followed the instructions to the letter, the 'EmailDataSource.doc' wouldn't even exist at that point.

    Regarding:
    I then put in your suggested code (under "Merging by catalog/Directory to E-Mail") into the Mailmerge Main document and then selected Mailings --> Select Recipients and connected this to the excel file.
    I don't see any indication you configured it for a Catalog/Directory mailmerge.

    And as for:
    When I run the code, I am receiving the following error: "Object Variable or With block variable not set"
    Since you only say you edited the 'Email Merge Main Document' and don't say you saved it in the .doc format as the instructions tell you to and my last post reiterated, the code can't be expected to work - so far as it's concerned, the document it's looking for doesn't exist.

  7. #7
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: Mail Merge to Email

    Paul,

    I apologize if I am frustrating you, but I read through your entire tutorial and perhaps am too much of a beginner for some of your language. In regards to your commentary, the two files from your zip were already configured under "E-Mail Messages" and "Directory" under the "Start Mail Merge" drop-down. Your files were also already saved in the .doc format, and I made no changes to either of those.

    As for why I chose to use the "EmailDataSource" file as the connection, I did not see the "Recipient" field in any other file, and it was not listed anywhere in your instructions, so I came to that conclusion on my own.

    I will look elsewhere for the answer to my question, but I appreciate your help.

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Email

    Quote Originally Posted by NicoleAL123 View Post
    In regards to your commentary, the two files from your zip were already configured under "E-Mail Messages" and "Directory" under the "Start Mail Merge" drop-down. Your files were also already saved in the .doc format, and I made no changes to either of those.
    That may be so, but your own attachments to post 3 were in the .docx format and the tutorial process, when applied to the sample documents included with the tutorial, works 100%.
    Quote Originally Posted by NicoleAL123 View Post
    I will look elsewhere for the answer to my question
    My reply in post #2 refers to alternate methods, including the use of a DATABASE field and the use of a Many-to-One Mail Merge add-in, for which two sources were provided.

+ 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. How to do a Mail Merge With CC Email
    By Kingswood in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-25-2015, 04:25 PM
  2. [SOLVED] Split mail merge letters and send email
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-03-2015, 11:21 AM
  3. Mail Merge and Send Fax via Email
    By Gos-C in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2015, 03:31 PM
  4. [SOLVED] Catalogue/Directory Mail Merge to email = Hitting a brick Wall! Help, Please...!
    By RossInk in forum Word Formatting & General
    Replies: 11
    Last Post: 06-03-2014, 08:11 PM
  5. Macro to email HTML formatted mail merge from list in excel
    By jamesshakedown in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-19-2013, 10:14 AM
  6. [SOLVED] Excel sheet mail merge to email?
    By tavyabe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-18-2012, 09:18 AM
  7. mail merge to email
    By newangel90 in forum Word Formatting & General
    Replies: 1
    Last Post: 12-10-2010, 12:53 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