georgeeasten
06-16-2011, 06:27 AM
Hi All,
I have the following which generates a reply with a signature simply saying "George". At the moment I have it attaching the original message because I cannot work out how to reply with the original mail in the body of the message.
I have chopped up several different codes from different sources so not sure if this is the best way to approach it?!
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub InternalReply()
Dim Msg As Outlook.MailItem
Dim MsgReply As Outlook.MailItem
Dim SigString As String
On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set Msg = ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set Msg = ActiveInspector.CurrentItem
Case Else
End Select
SigString = "C:\Documents and Settings\" & Environ("username") & "\Application Data\Microsoft\Signatures\Internal Reply.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
Set MsgReply = Msg.Reply
With MsgReply
.Subject = "RE: " & Msg.Subject
.HTMLBody = "<span style=""font-family : calibri;font-size : 11pt" & ",</p></span>" & Signature & ReplyMsg
.Attachments.Add Msg
.Display
End With
Set Msg = Nothing
Set MsgReply = Nothing
End Sub
I'm sure there must be a way of using a template to reply and then include the original message by including it with a 'with' statement?
I already have a template setup with the following for internal mail:Sub CreateInternalMail()
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
Set objMail = olApp.CreateItemFromTemplate("C:\Documents and Settings\georgee\Application Data\Microsoft\Templates\Internal.oft")
objMail.Display
End Sub
It seems to be so difficult to just create a new email or use the reply function. It is so much easier in word with the Documents.Add function.
Help greatly received - this is my first time working with Outlook VBA
I have the following which generates a reply with a signature simply saying "George". At the moment I have it attaching the original message because I cannot work out how to reply with the original mail in the body of the message.
I have chopped up several different codes from different sources so not sure if this is the best way to approach it?!
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub InternalReply()
Dim Msg As Outlook.MailItem
Dim MsgReply As Outlook.MailItem
Dim SigString As String
On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set Msg = ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set Msg = ActiveInspector.CurrentItem
Case Else
End Select
SigString = "C:\Documents and Settings\" & Environ("username") & "\Application Data\Microsoft\Signatures\Internal Reply.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
Set MsgReply = Msg.Reply
With MsgReply
.Subject = "RE: " & Msg.Subject
.HTMLBody = "<span style=""font-family : calibri;font-size : 11pt" & ",</p></span>" & Signature & ReplyMsg
.Attachments.Add Msg
.Display
End With
Set Msg = Nothing
Set MsgReply = Nothing
End Sub
I'm sure there must be a way of using a template to reply and then include the original message by including it with a 'with' statement?
I already have a template setup with the following for internal mail:Sub CreateInternalMail()
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
Set objMail = olApp.CreateItemFromTemplate("C:\Documents and Settings\georgee\Application Data\Microsoft\Templates\Internal.oft")
objMail.Display
End Sub
It seems to be so difficult to just create a new email or use the reply function. It is so much easier in word with the Documents.Add function.
Help greatly received - this is my first time working with Outlook VBA