New Message vs Replies

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
I want to use the user's Outlook "New Message" default email signature but my code is using the replies/forwards email address. How do I distinguish since the user can name it anything? Thanks

Code:
Call SendMessage(ToRecipients, CCRecipients, BCCRecipients, stSubject, vaMsg, imAttachment, senderstr)

calls function...

Code:
Sub SendMessage(myRecipient As String, mycc As String, mybcc As String, mySubject As String, Optional myBody As String, Optional myFileName As String, Optional mySender As String)
On Error Resume Next
Dim myObject As Object
Dim myItem As Object
Dim strarray As String
Dim strunbound() As String
Dim Z As Long
Dim sSignat As Variant
Dim sPath As String


Set myObject = CreateObject("Outlook.Application")
Set myItem = myObject.CreateItem(0)


With myItem
.display
.Subject = mySubject
.To = myRecipient
.cc = mycc
.bcc = mybcc
If Trim(mySender) <> "" Then
.SentOnBehalfOfName = mySender
End If
If Trim(myBody) <> "" Then
'.Body = myBody


sPath = Dir(Environ("appdata") & "\Microsoft\Signatures\*.htm", vbNormal)
        sPath = Environ("appdata") & "\Microsoft\Signatures\" & sPath
        sSignat = GetSignature(sPath)
        'MsgBox sSignat
      '.HTMLBody = myBody & String(4, vbCrLf) & sSignat


'.HTMLBody = myBody & "<br>" & .HTMLBody
.HTMLBody = myBody & sSignat '& "<br>" & .HTMLBody
End If


'attach one file
If Trim(myFileName) <> "" Then
If InStr(myFileName, ",") = 0 Then
If Dir(myFileName) <> "" Then
.Attachments.Add (myFileName)
End If
Else 'multiple files
strarray = myFileName
 strunbound = Split(myFileName, ",")
 For Z = LBound(strunbound) To UBound(strunbound)
 .Attachments.Add (strunbound(Z))
Next Z
End If
End If
.Send
End With


Set myItem = Nothing
Set myObject = Nothing
End Sub
 
You could of course try

Rich (BB code):
Set OA = CreateObject("Outlook.Application")
Set OM = OA.CreateItem(0)
Signature = OM.HTMLBody

'--------------..ooOO0OOoo..--------------

'Do some other coding here

'--------------..ooOO0OOoo..--------------

With OM
    .Display
    .HTMLBody = "SomeText" & Signature
End With
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,760
Messages
6,174,339
Members
452,555
Latest member
colc007

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