I am trying to pull text between two symbols:
S1 | STAR2449524 | XYZ Bank | 1 - Critical |Health Service Heartbeat Failure.
I need to extract
| XYZ Bank |
Which is between 2'nd appearance of symbol and place it in my template where variable name is COMP1 |
This is my code
S1 | ICM21449524 | XYZ Bank | P1 - Critical |Health Service Heartbeat Failure.
Sub Reply_Test()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Dim oRespond As Outlook.MailItem
Dim INC1 As String 'For Incident Number
Dim INo As Integer 'For Incident Number
Dim COMP1 As String 'For Company Name
Dim Com As Integer 'For Company Name
Dim ISSU1 As String ' For Issue
Dim Isu As Integer 'for Issue
Dim varSplit As Variant
'Dim msginfo As msg.Subject (Tried using not worked)
varSplit = Split("New incident |S1 | ICM1449524 | XYZ Bank | P1 - Critical |Health Service Heartbeat Failure.", "|")
'varSplit = Split(msginfo, "|") (Tried using not worked)
strSubject1 = varSplit(0)
strSubject2 = varSplit(1)
strSubject3 = varSplit(2)
strSubject4 = varSplit(3)
strSubject5 = varSplit(4)
Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate("H:\Documents\CLOSED P1.oft")
replyEmail.To = origEmail.Reply.To
replyEmail.CC = "abc@xyz.com"
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Subject = replyEmail.Subject & origEmail.Reply.Subject
replyEmail.Subject = " <P1> - " & strSubject2 & " " & "For" & " " & strSubject3
replyEmail.Display
End Sub
This is a working code. But I get emails frequently with a different subject line but pattern resembles. So whenever I get an email I need to forward with the unique subject (<S1> ICM# for XYZ Bank). So my concern is I need to assign a variable to my subject and splitting it using split function every time. Above code, I am not able to assign the variable to subject which will enable me to use the same code for every email.
S1 | STAR2449524 | XYZ Bank | 1 - Critical |Health Service Heartbeat Failure.
I need to extract
| XYZ Bank |
Which is between 2'nd appearance of symbol and place it in my template where variable name is COMP1 |
This is my code
S1 | ICM21449524 | XYZ Bank | P1 - Critical |Health Service Heartbeat Failure.
Sub Reply_Test()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Dim oRespond As Outlook.MailItem
Dim INC1 As String 'For Incident Number
Dim INo As Integer 'For Incident Number
Dim COMP1 As String 'For Company Name
Dim Com As Integer 'For Company Name
Dim ISSU1 As String ' For Issue
Dim Isu As Integer 'for Issue
Dim varSplit As Variant
'Dim msginfo As msg.Subject (Tried using not worked)
varSplit = Split("New incident |S1 | ICM1449524 | XYZ Bank | P1 - Critical |Health Service Heartbeat Failure.", "|")
'varSplit = Split(msginfo, "|") (Tried using not worked)
strSubject1 = varSplit(0)
strSubject2 = varSplit(1)
strSubject3 = varSplit(2)
strSubject4 = varSplit(3)
strSubject5 = varSplit(4)
Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate("H:\Documents\CLOSED P1.oft")
replyEmail.To = origEmail.Reply.To
replyEmail.CC = "abc@xyz.com"
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Subject = replyEmail.Subject & origEmail.Reply.Subject
replyEmail.Subject = " <P1> - " & strSubject2 & " " & "For" & " " & strSubject3
replyEmail.Display
End Sub
This is a working code. But I get emails frequently with a different subject line but pattern resembles. So whenever I get an email I need to forward with the unique subject (<S1> ICM# for XYZ Bank). So my concern is I need to assign a variable to my subject and splitting it using split function every time. Above code, I am not able to assign the variable to subject which will enable me to use the same code for every email.