Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2021, 06:09 PM
trevorc trevorc is offline creating HTML code for email Windows 7 32bit creating HTML code for email Office 2013
Competent Performer
creating HTML code for email
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default creating HTML code for email

Hi all,
I am trying to create some HTML code that does the following in the body of the email

Hi,
Name of person

Here is your invoice # 123456 PAID more text and end of email

The code below does this but won't let me put the mixed color,size,bold on the same line as normal text, it does do all the other things i need it to do.

Any help would be appreciated
the email is automated to attached 2 files and then display it


regards
Trevor
On a side note how do i attache an image at the bottom of the email body?

See code below


Code:
            .HTMLBody = .HTMLBody & "Hi " & Intersect(acrow, tblColumns("Contact Name").Range) & ", <br/> Please find attached a copy of your invoice and a copy of the online banking receipt,<br>for the repair of your Unit RMA Number - " & Intersect(acrow, tblColumns("RMA Number").Range) & " <span style=""color:#FF0000""><p style='font-family:calibri;font-size:20'><b>(PAID with provided credit card details)</b></p></span style=""color:#FF0000"">"
            .HTMLBody = .HTMLBody & "<br/>Dispatched on " & Date & " via Post<br/><br/>Regards,<br/>Trevor<br/>Workshop Manager<br/>Mobile 0404 123 456  <br/>E-mail trevor@here.com <br/> company Pty Ltd<br/>Any views expressed in this Communication are those of the individual sender and do not necessarily reflect the views of"
Reply With Quote
  #2  
Old 05-17-2021, 06:22 PM
Logit Logit is offline creating HTML code for email Windows 10 creating HTML code for email Office 2007
Expert
 
Join Date: Jan 2017
Posts: 529
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Here's an example you might be able to apply :

Code:
"<font face=""Times New Roman"" size=""2"" color=""blue""><i>""STANDARDIZATION & COMPLIANCE""</i></font>"
Reply With Quote
  #3  
Old 05-17-2021, 07:39 PM
trevorc trevorc is offline creating HTML code for email Windows 7 32bit creating HTML code for email Office 2013
Competent Performer
creating HTML code for email
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

I'll check it out tomorrow, thanks for the idea.
Reply With Quote
  #4  
Old 05-17-2021, 07:41 PM
macropod's Avatar
macropod macropod is offline creating HTML code for email Windows 10 creating HTML code for email Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could, of course, use mailmerge...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-17-2021, 08:30 PM
gmayor's Avatar
gmayor gmayor is offline creating HTML code for email Windows 10 creating HTML code for email Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

For multiple messages, as Paul suggests, mailmerge is the obvious approach - see E-Mail Merge Add-in

For individual messages rather than use html codes, the better approach is to use the Outlook word editor. You will need to copy a function from the web page indicated in the code to ensure Outlook is started correctly.

Using this method is simpler as it does not require long strings of html code, and is similar to VBA programming in Word.

Insert the appropriate Excel ranges for name, e-mail address and invoice number in place of the fixed values in the code.

Code:
Public Sub CreateEmail()
'Graham Mayor - https://www.gmayor.com - Last updated - 18 May 2021
'Requires the code - http://www.rondebruin.nl/win/s1/outlook/openclose.htm
'to either retrieve an open instance of Outlook or open Outlook if it is closed.
Dim olApp As Object
Dim olMail As Object        ' Outlook.MailItem
Dim olInsp As Object        ' Outlook.Inspector
Dim wdDoc As Object        ' Word.Document
Dim wdRange As Object        ' Word.Range

    Set olApp = OutlookApp()
    Set olMail = olApp.CreateItem(0)
    With olMail
        .BodyFormat = 2
        .Display
        .To = "someone@somewhere.com"
        .Subject = "Message Subject"
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set wdRange = wdDoc.Range
        With wdRange
            .collapse 1
            .Font.Color = RGB(0, 0, 0)
            .Font.Size = 11
            .Font.Bold = False

            .Text = "Hi, " & "Name of person" & vbCr & vbCr & _
                    "Here is your invoice # " & "123456"
            .collapse 0

            .Text = " PAID "
            .Font.Color = RGB(255, 0, 0)
            .Font.Size = 16
            .Font.Bold = True
            .collapse 0

            .Text = "more text and end of email"    'signature associated with account is retained.
            .Font.Color = RGB(0, 0, 0)
            .Font.Size = 11
            .Font.Bold = False
        End With
    End With
lbl_Exit:
    Set wdRange = Nothing
    Set wdDoc = Nothing
    Set olInsp = Nothing
    Set olMail = Nothing
    Set olApp = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com

Last edited by gmayor; 05-17-2021 at 11:10 PM.
Reply With Quote
  #6  
Old 05-17-2021, 08:54 PM
trevorc trevorc is offline creating HTML code for email Windows 7 32bit creating HTML code for email Office 2013
Competent Performer
creating HTML code for email
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Thanks for that, I do like the look of that and I should still be able to add in all the text from my table row eg Intersect(acrow, tblColumns("Contact Name").Range) and then spit it out to mailmerge. I'll let you know how i get on by Friday.
regards
Trevor

PS thanks for the detailed example.
Reply With Quote
  #7  
Old 05-17-2021, 09:29 PM
trevorc trevorc is offline creating HTML code for email Windows 7 32bit creating HTML code for email Office 2013
Competent Performer
creating HTML code for email
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Well i had some spare time and have now got this going just right. Thanks for your assistance with this.

regards
Trevor
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating HTML code for email Using VBA to find html img code, and insert images dynamically noslenwerd Word VBA 3 01-02-2020 02:14 PM
how to add voting buttons in email content html code nikyc Outlook 1 11-21-2019 11:50 PM
creating HTML code for email Macro Help Swapping HTML Code pclark2 Word VBA 2 02-11-2019 03:25 PM
Search and replace/insert HTML code into Master File using tags dave8555 Excel 2 02-23-2014 03:51 PM
Strange HTML code inside an e-mail Joostdegrote Outlook 0 09-13-2010 07:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:50 AM.


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