PDA

View Full Version : Help sending email but removing signature via VBA



molonlabe
05-11-2018, 05:40 AM
I have my primary email and then I can send from another (Alt email), but that alt email is not an account that is added to my outlook, but I can send/receive from it. Hope that makes sense. Since the alt email account is not added, then I can't set it to have a default signature. Therefore I use this code to open a template and change the sending from. Problem is that it still adds the default signature. Before I could alter the registry to stop this, but I can no longer access the registry. I need a way to open the template without adding my default signature. Can anyone help!?


'Opens Email Disclosure TemplateSub OpenEmailTemplate()
Dim oAccount As Outlook.Account




For Each oAccount In Application.Session.Accounts
' If oAccount = "testATtest.com" Then
Set temp = Application.CreateItemFromTemplate("file path here")
temp.SentOnBehalfOfName = "sendATtest.com"
temp.Subject = "PERSONAL AND CONFIDENTIAL COMMUNICATION"


temp.Display


'End If
Next
Set temp = Nothing
End Sub

gmayor
05-11-2018, 09:56 PM
Your code as posted creates a message for each account? However you could edit the message to remove the signature. In the line
Rng.moveStart 4, -3
change the -3 as required to remove the appropriate number of paragraph from the end of the message.


'Opens Email Disclosure Template
Sub OpenEmailTemplate()
Dim oAccount As Outlook.Account
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object

Dim oTemp As MailItem
For Each oAccount In Application.Session.Accounts
' If oAccount = "testATtest.com" Then
Set oTemp = Application.CreateItemFromTemplate("file path here")
With oTemp
.SentOnBehalfOfName = "sendATtest.com"
.Subject = "PERSONAL AND CONFIDENTIAL COMMUNICATION"
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
oRng.collapse 0
oRng.moveStart 4, -3
oRng.Delete
.Display

End With
'Exit For

'End If
Next
Set oTemp = Nothing
Set oAccount = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
End Sub