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
calls function...
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