NovelVisual_1972
Member
- Outlook version
- Outlook 2019 64-bit
- Email Account
- Outlook.com (as MS Exchange)
Dear Diana, partners:
With the pleasure of greeting you, I have the following problem that I would be very grateful for if you could help me solve it.
In fact, I already checked this same page so as not to repeat something that may already have an answer and I found a similar topic;
<Auto forward email that is moves into a specific outlook folder>
But since it has certain differences I dare to explain my situation. Thanks in advance.
Although I have some knowledge of VBA, I am practically new to Outlook VBA, so I require your invaluable help to resolve the following:
The following code, being from an itemadd macro, was placed in "ThisOutlookSession"
Option Explicit
'// items in the target folder to events
Dim WithEvents TargetFolderItems As Items
Private Sub Application_Startup()
Dim olNamespace As Outlook.NameSpace
Set olNamespace = Application.GetNamespace("MAPI")
'// Set your folder here
Set TargetFolderItems = olNamespace.GetDefaultFolder(olFolderInbox) _
.Folders.Item("REPLY").Items
End Sub
'// ItemAdd event code
Sub TargetFolderItems_ItemAdd(ByVal Item As Object)
Dim olReply As MailItem
'Email Body Text
Dim xOutMsg As String
'Define the final text of the email body
Dim emReplyFinal As String
Dim CustName As String
'Email body text goes here
emReplyFinal = "<HTML><BODY> <div style=""text-align:justify""><span style='font-family: ""Montserrat"" '><span style='font-size:10.5pt'>" & _
" <p>LONG text LONG text LONG text LONG text LONG text LONG text LONG text " & _
" <b> Document name in the referenced link</b> " & _
"<a href=""Hyperlink to document"">" & _
" LONG text LONG text LONG text LONG text LONG text LONG text LONG text LONG""</a><br><br>" & _
"Greetings.</a>" & _
"<p></font></font> </BODY></HTML>"
Set olReply = Item.Reply
CustName = olReply.To
xOutMsg = "<p style='font-family:Montserrat;FontStyle:Normal;font-size:10.5pt'>" & _
"Apreciable " & CustName & ":" & emReplyFinal
olReply.HTMLBody = xOutMsg & vbCrLf & olReply.HTMLBody
olReply.Send
Set TargetFolderItems = Nothing
Set olReply = Nothing
End Sub
The thing is that, when you enter the code in Outlook, and verify that it works, it does, but only with a single message that is moved to the “REPLY” folder of Outlook and, furthermore, it is not constant since I have to close the application to get it used and working again.
I require it to work without closing and opening Outlook for use and that it also work with multiple messages that I move to said “REPLY” folder. Excuse my poor English, but broadly speaking that is my problem.
I do not omit to tell you that I am a newbie to Outlook macros and it has been a bit complicated for me to understand the process, but I have already searched and searched for a way to adapt it for the use I require, only there is no solution.
Waiting for your valuable help. Thanks for the attention.
With the pleasure of greeting you, I have the following problem that I would be very grateful for if you could help me solve it.
In fact, I already checked this same page so as not to repeat something that may already have an answer and I found a similar topic;
<Auto forward email that is moves into a specific outlook folder>
But since it has certain differences I dare to explain my situation. Thanks in advance.
Although I have some knowledge of VBA, I am practically new to Outlook VBA, so I require your invaluable help to resolve the following:
The following code, being from an itemadd macro, was placed in "ThisOutlookSession"
Option Explicit
'// items in the target folder to events
Dim WithEvents TargetFolderItems As Items
Private Sub Application_Startup()
Dim olNamespace As Outlook.NameSpace
Set olNamespace = Application.GetNamespace("MAPI")
'// Set your folder here
Set TargetFolderItems = olNamespace.GetDefaultFolder(olFolderInbox) _
.Folders.Item("REPLY").Items
End Sub
'// ItemAdd event code
Sub TargetFolderItems_ItemAdd(ByVal Item As Object)
Dim olReply As MailItem
'Email Body Text
Dim xOutMsg As String
'Define the final text of the email body
Dim emReplyFinal As String
Dim CustName As String
'Email body text goes here
emReplyFinal = "<HTML><BODY> <div style=""text-align:justify""><span style='font-family: ""Montserrat"" '><span style='font-size:10.5pt'>" & _
" <p>LONG text LONG text LONG text LONG text LONG text LONG text LONG text " & _
" <b> Document name in the referenced link</b> " & _
"<a href=""Hyperlink to document"">" & _
" LONG text LONG text LONG text LONG text LONG text LONG text LONG text LONG""</a><br><br>" & _
"Greetings.</a>" & _
"<p></font></font> </BODY></HTML>"
Set olReply = Item.Reply
CustName = olReply.To
xOutMsg = "<p style='font-family:Montserrat;FontStyle:Normal;font-size:10.5pt'>" & _
"Apreciable " & CustName & ":" & emReplyFinal
olReply.HTMLBody = xOutMsg & vbCrLf & olReply.HTMLBody
olReply.Send
Set TargetFolderItems = Nothing
Set olReply = Nothing
End Sub
The thing is that, when you enter the code in Outlook, and verify that it works, it does, but only with a single message that is moved to the “REPLY” folder of Outlook and, furthermore, it is not constant since I have to close the application to get it used and working again.
I require it to work without closing and opening Outlook for use and that it also work with multiple messages that I move to said “REPLY” folder. Excuse my poor English, but broadly speaking that is my problem.
I do not omit to tell you that I am a newbie to Outlook macros and it has been a bit complicated for me to understand the process, but I have already searched and searched for a way to adapt it for the use I require, only there is no solution.
Waiting for your valuable help. Thanks for the attention.