Home > OS >  How to temporally set signature of (Replies/Forwards) to be `None`?
How to temporally set signature of (Replies/Forwards) to be `None`?

Time:12-17

There are a lot of questions here on ST to delete signature when Auto-Forward incoming emails using vba,
But, until now there is no accepted answers for that issue.
So, I got an idea , If it possible to temporally set signature of (Replies/Forwards) to be None, using own vba or windows registry setting. I mean at beginning of the Sub objInboxItems_ItemAdd to set signature of (Replies/Forwards) to be None and at end revert it back to my previous signature.

enter image description here

Public WithEvents objInbox As Outlook.Folder
Public WithEvents objInboxItems As Outlook.Items
 
Private Sub Application_Startup()
    Set objInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
    Set objInboxItems = objInbox.Items
End Sub
 
Private Sub objInboxItems_ItemAdd(ByVal item As Object)            
    Dim objMail As Outlook.MailItem
    Dim objForward As Outlook.MailItem
 
    If Not TypeOf item Is MailItem Then Exit Sub
 
        Set objMail = item
        Set objForward = objMail.Forward
 
        'Customize the forward subject, body and recipients'
        With objForward
            .Recipients.Add ("[email protected]")
            .Recipients.ResolveAll
            .Send
        End With
End Sub

In advance , grateful for all your help.

CodePudding user response:

As I said in my comment, the next suggested solution delete signature, if exists...

Please, copy the next sub in the project dealing with Outlook forward automation:

Sub ClearSignature(oMail As Object)
        Dim objWdEd As Object, oBjBookM As Object
        Set objWdEd = oMail.GetInspector.WordEditor
        On Error GoTo NoSignature
        Set oBjBookM = objWdEd.Bookmarks("_MailAutoSig")
          oBjBookM.Range.Delete
          Exit Sub
        
NoSignature:
        Debug.Print "No Any Signature found..." 'it may be commented...
End Sub

The following part of your code should be adapted as:

 'your existing code...
       With objForward
            .Recipients.Add ("[email protected]")
            .Recipients.ResolveAll
            'inserted lines _______________________
              .Display 'to load signature, if any...
              ClearSignature objForward  'to clear the signature (if any)
             '_____________________________________
            .Send
        End With
 'your existing code

The suggested solution has the disadvantage if screen flickering (display it for short time, before sending), in case of mass forwarding...

CodePudding user response:

On the Extended MAPI level (C or Delphi), you can use enter image description here

If Extended MAPI is not an option, you can use Redemption (any language, I am also its author) - is exposes New and Reply signatures on the RDOAccount object:

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Account = Session.Accounts.GetOrder(2).Item(1) 'first mail account
if Not (Account Is Nothing) Then
  set Signature = Account.ReplySignature
  Account.ReplySignature = Nothing
  ' do something
  ' then restore the reply signature
  Account.ReplySignature = Signature
End If
  • Related