View Single Post
 
Old 08-12-2019, 08:51 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
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 ofgmayor has much to be proud of
Default

Instead of mailenvelope, try the following

Code:
Sub Send_As_HTML_EMail()
'Graham Mayor - http://www.gmayor.com - Last updated - 14 Jul 2017
'Requires the code from 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 bStarted As Boolean
Dim olApp As Object
Dim oItem As Object
Dim oAccount As Object
Dim objDoc As Object
Dim objSel As Selection
Dim strRecipient As String
Dim strSubject As String
Dim strAccount As String

    strRecipient = "someone@somewhere.com"
    strSubject = "This is the message subject"
    strAccount = "account display name"

    ActiveDocument.Range.Copy
    Set olApp = OutlookApp()

    For Each oAccount In olApp.Session.Accounts
        If oAccount.DisplayName = strAccount Then
            Set oItem = olApp.CreateItem(0)
            With oItem
                Set .SendUsingAccount = oAccount
                .BodyFormat = 2
                .Display
                Set objDoc = .GetInspector.WordEditor
                Set objSel = objDoc.Windows(1).Selection
                objSel.PasteAndFormat Type:=wdFormatOriginalFormatting
                .To = strRecipient
                .Subject = strSubject
                '.Send
            End With
            Exit For
        End If
    Next oAccount
lbl_Exit:
    Set oItem = Nothing
    Set oAccount = Nothing
    Set olApp = Nothing
    Set objDoc = Nothing
    Set objSel = 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
Reply With Quote