Issue with setting XML output to outlook

selkov

Well-known Member
Joined
Jan 26, 2004
Messages
787
This is beyond me or I may just be brain dead. But I have the following code that gets for me the email signature associated with the email account:

'get Email Sig
Set objOutlookApp = CreateObject("Outlook.Application")
With objOutlookApp.CreateItem(0)
With .GetInspector: End With
EmS = .HtmlBody
.display
End With


And this bit of code that creates an outlook instance and pastes the html data created elsewhere from an excel spreadsheet.

Set objOutlookApp = CreateObject("Outlook.Application")
Set objNewEmail = objOutlookApp.CreateItem(olMailItem)
'Read the HTML file data and insert into the email body
Set objTextStream = objFileSystem.OpenTextFile(strTempHTMLFile)
objTextStream = objTextStream
objNewEmail.HtmlBody = objTextStream.ReadAll



The issue I am having is I can only insert one HTML or the other. How can I add the Signature to the end of the email body?

Thanks for the help...
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
For signature you need to get this function in a module

Code:
Function GetBoiler(ByVal sFile As String) As StringDim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close 
End Function

End then you can use this for mail where you change signature1

Code:
[COLOR=#333333]Sub Saveaspdfandsend()
[/COLOR]Dim xSht As Worksheet
Dim xFileDlg As FileDialog
Dim xFolder As String
Dim xOutlookObj As Object
Dim xEmailObj As Object
Dim xUsedRng As Range
Dim xStr As String
Set xSht = ActiveSheet
xFolder = "Sub Saveaspdfandsend()Dim xSht As Worksheet
Dim xFileDlg As FileDialog
Dim xFolder As String
Dim xOutlookObj As Object
Dim xEmailObj As Object
Dim xUsedRng As Range
Dim xStr As String
Set xSht = ActiveSheet
xFolder = "c:\users\[COLOR=#ff0000]YourName[/COLOR]\Desktop"
xStr = Format(Date, "ddmmyyyy")
xFolder = xFolder & "InventoryShiftReport" & "_" & xStr & "_" & Environ("Username") & ".pdf"
xSht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=xFolder, Quality:=xlQualityStandard
'Create Outlook email
Set xOutlookObj = CreateObject("Outlook.Application")
Set xEmailObj = xOutlookObj.CreateItem(0)
On Error Resume Next
'Body
Dim strbody As String
strbody = "[B]your body[/B]"
'Signature
'Change only Signature1 to the name of your signature
    Dim SigString As String
Dim Signature As String
    SigString = Environ("appdata") & _
                "\Microsoft\Signatures\[COLOR=#ff0000]Signature1[/COLOR].htm"
    If Dir(SigString) <> "" Then
        Signature = GetBoiler(SigString)
    Else
        Signature = ""
    End If
With xEmailObj
.Display
.To = ""
.CC = ""
.Subject = "your subject " & Date
.Attachments.Add xFolder
.HTMLBody = strbody & "" & Signature
End With


[FONT=Verdana]End Sub[/FONT]
 
Last edited:
Upvote 0
That seems to address more than I need and will entail re-writing a good bit of code. Right now there is two HTML outputs that work independently. I just need some way to combine them
 
Upvote 0
Arg that hurts my head. I will work wit it and see if I can et t to work. thanks for the direction.
 
Upvote 0

Forum statistics

Threads
1,223,631
Messages
6,173,465
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top