Microsoft Office Forums Pass Mailmerge body to Outlook Application

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-11-2019, 09:21 AM
Wordeo Wordeo is offline Pass Mailmerge body to Outlook Application Windows 10 Pass Mailmerge body to Outlook Application Office 2016
Novice
Pass Mailmerge body to Outlook Application
 
Join Date: Feb 2019
Posts: 1
Wordeo is on a distinguished road
Default Pass Mailmerge body to Outlook Application

I'm working off of mailmerge VBA code that uses .MailMerge


now I'm passing values to from .MailMerge to field fields in Outlook.MailItem because I find it easier to reference the column using .MailItem


for example:


Quote:
myItem.To = ("email")


myItem.Subject = ("Probationary Period

I'm trying to fill out .HTMLBody but it won't compile because I don't know how to use the mailmerge email body as a string or an html from .MailMerge that I can forward to .body or .HTMLbody for Outlook.Application / Outlook.MailItem




These my attempts so far:


declaring



Quote:
Dim myItem As Outlook.MailItem

with attempts such as



  1. Quote:
    myItem.HTMLBody = .DataSource & myItem.Body
  2. Quote:
    myItem.HTMLBody = .DataSource






If I can somehow use the MailMerge method to pass the the mail merge document to the body of the Outlook method it would really save me a lot of time


Please advise
Reply With Quote
  #2  
Old 03-11-2019, 01:35 PM
macropod's Avatar
macropod macropod is offline Pass Mailmerge body to Outlook Application Windows 7 64bit Pass Mailmerge body to Outlook Application Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Mailmerge doesn't automate Outlook, so code like you've posted is irrelevant in that context; you'd have to forego mailmerge entirely and automate Outlook instead, writing your own code for the entire process.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 03-11-2019, 11:07 PM
gmayor's Avatar
gmayor gmayor is offline Pass Mailmerge body to Outlook Application Windows 10 Pass Mailmerge body to Outlook Application Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,805
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

In order to write to the html body, you need to use the Outlook Word Editor Inspector and then you can treat the body as if it was a Word document e.g.


Code:
With olEmail
        .BodyFormat = olFormatHTML
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        oRng.Collapse 1
This entry point at the start or the message body. As long as you know how to manipulate strings you can add whatever you want to that body.


Or you could simply use http://www.gmayor.com/ManyToOne.htm in one to one mode and merge directly to the message body
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
.datasource, html body template, mailmerge

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
configure outlook for gmail. cannot pass msg lortech Outlook 0 12-15-2015 11:58 PM
add hyperlink in body of Outlook email ChuckDrago Word 0 06-27-2013 01:13 PM
Pass Mailmerge body to Outlook Application Outlook Mailmerge - Application Crash pgrant Word 4 12-05-2011 04:51 AM
Outlook 2007 Application Hang MTomasco Outlook 1 06-06-2011 11:53 PM
Outlook 2007 Application Hang outlook_n00b Outlook 0 03-31-2011 11:19 AM


All times are GMT -7. The time now is 02:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft