Hello everyone,
to be able to use In-line reply style, I copied following VBA code into my Outlook (source: Matthijs van de Water - In-line reply style in Outlook
Sub ReplyAllPlain()
Dim app As New Outlook.Application
Dim exp As Outlook.Explorer
Set exp = app.ActiveExplorer
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim item As Outlook.MailItem
'Get MailItem based on EntryID, otherwise we'll get security warnings
strID = exp.Selection.item(1).EntryID
Set olNS = Application.GetNamespace("MAPI")
Set item = olNS.GetItemFromID(strID)
' Store name of the sender and date of sent message
Dim name As String
name = item.SentOnBehalfOfName
datestr = Format(item.SentOn, "DDD, MMM dd, yyyy at HH:mm:ss")
' ReplyToAll to this message in Plain formatting with > style
item.BodyFormat = olFormatPlain
item.Actions("Reply to All").ReplyStyle = olReplyTickOriginalText
Dim rply As Outlook.MailItem
Set rply = item.ReplyAll
' Rebuild original body:
' - Remove Outlook-style reply header
' - Get rid of auto-inserted signature (optionally move to end of message)
orgBody = rply.Body
pos = InStr(orgBody, ">") - 1
sig = Left(orgBody, pos)
myBody = Mid(orgBody, pos + 1)
b = 0
lines = Split(myBody, vbNewLine)
For Each myLine In lines
If b > 4 Then
newBody = newBody & myLine & vbNewLine
End If
b = b + 1
Next
' Put new body together
rply.Body = "On " & datestr & ", " & name & " wrote:" _
& vbNewLine & newBody & vbNewLine '& sig
rply.Display
item.Close olDiscard
End Sub
Unfortunatelly, this macro will be stopped with run time error 91: object variable or with block variable not set. I guess, this happens at the beginning of part
' Rebuild original body:
' - Remove Outlook-style reply header
' - Get rid of auto-inserted signature (optionally move to end of message)
Could you please check this code and correct it? Thank's a lot in advance.
to be able to use In-line reply style, I copied following VBA code into my Outlook (source: Matthijs van de Water - In-line reply style in Outlook
Sub ReplyAllPlain()
Dim app As New Outlook.Application
Dim exp As Outlook.Explorer
Set exp = app.ActiveExplorer
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim item As Outlook.MailItem
'Get MailItem based on EntryID, otherwise we'll get security warnings
strID = exp.Selection.item(1).EntryID
Set olNS = Application.GetNamespace("MAPI")
Set item = olNS.GetItemFromID(strID)
' Store name of the sender and date of sent message
Dim name As String
name = item.SentOnBehalfOfName
datestr = Format(item.SentOn, "DDD, MMM dd, yyyy at HH:mm:ss")
' ReplyToAll to this message in Plain formatting with > style
item.BodyFormat = olFormatPlain
item.Actions("Reply to All").ReplyStyle = olReplyTickOriginalText
Dim rply As Outlook.MailItem
Set rply = item.ReplyAll
' Rebuild original body:
' - Remove Outlook-style reply header
' - Get rid of auto-inserted signature (optionally move to end of message)
orgBody = rply.Body
pos = InStr(orgBody, ">") - 1
sig = Left(orgBody, pos)
myBody = Mid(orgBody, pos + 1)
b = 0
lines = Split(myBody, vbNewLine)
For Each myLine In lines
If b > 4 Then
newBody = newBody & myLine & vbNewLine
End If
b = b + 1
Next
' Put new body together
rply.Body = "On " & datestr & ", " & name & " wrote:" _
& vbNewLine & newBody & vbNewLine '& sig
rply.Display
item.Close olDiscard
End Sub
Unfortunatelly, this macro will be stopped with run time error 91: object variable or with block variable not set. I guess, this happens at the beginning of part
' Rebuild original body:
' - Remove Outlook-style reply header
' - Get rid of auto-inserted signature (optionally move to end of message)
Could you please check this code and correct it? Thank's a lot in advance.