John_Mc
08-30-2007, 05:14 PM
Hi All,
As a newbie I've been playing with the code below that was written by Killian to reply to all messages that are selected at the time the macro button is hit, but am having some problems and can't figure out a solution.
When the txt file is read and put into the reply message, it deletes all the carriage returns, so everything is put next to each other, instead of having a blank line between paragraphs.
Also, I get a prompt asking for permission to send an email for each message - is there anyway of turning this off or only doing it once each time the macro is run?
Thanks for any help or advice you can offer,
Cheers,
John Mc
Sub main()
Dim myReply As MailItem
Dim objItem As MailItem
If Application.ActiveExplorer.Selection.Count > 0 Then
For Each objItem In Application.ActiveExplorer.Selection
If objItem.Class = olMail Then
Set myReply = objItem.Reply
myReply.Body = GetTextFromFile("C:\message.txt")
myReply.Display
End If
Next
End If
End Sub
Function GetTextFromFile(strPath As String) As String
Dim i As Long
Dim str As String
i = FreeFile
Open strPath For Input As #i
Do While Not EOF(1) ' Loop until end of file.
Input #i, str
GetTextFromFile = GetTextFromFile & str
Loop
Close
End Function
As a newbie I've been playing with the code below that was written by Killian to reply to all messages that are selected at the time the macro button is hit, but am having some problems and can't figure out a solution.
When the txt file is read and put into the reply message, it deletes all the carriage returns, so everything is put next to each other, instead of having a blank line between paragraphs.
Also, I get a prompt asking for permission to send an email for each message - is there anyway of turning this off or only doing it once each time the macro is run?
Thanks for any help or advice you can offer,
Cheers,
John Mc
Sub main()
Dim myReply As MailItem
Dim objItem As MailItem
If Application.ActiveExplorer.Selection.Count > 0 Then
For Each objItem In Application.ActiveExplorer.Selection
If objItem.Class = olMail Then
Set myReply = objItem.Reply
myReply.Body = GetTextFromFile("C:\message.txt")
myReply.Display
End If
Next
End If
End Sub
Function GetTextFromFile(strPath As String) As String
Dim i As Long
Dim str As String
i = FreeFile
Open strPath For Input As #i
Do While Not EOF(1) ' Loop until end of file.
Input #i, str
GetTextFromFile = GetTextFromFile & str
Loop
Close
End Function