Log in

View Full Version : How can I store the Subject Line in a Reply Email as String?



VBE313
12-26-2019, 10:30 AM
Private Sub test()Dim nameExample As String
Dim olItem As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim olReply As MailItem
Dim strTest As String, myItem As Outlook.MailItem
For Each olItem In Application.ActiveExplorer.Selection
nameExample = Split(olItem.SenderName, Chr(32))(0)
Set olReply = olItem.ReplyAll
strTest = olReply
olReply.Display
With olReply
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range(0, 0)
oRng.Text = "Hi " & nameExample & "," & vbCr & vbCr & _
"We are in receipt of your RFQ" & "(" & strTest & ")" & vbCr & vbCr & _
"Thanks," & vbCr & vbCr
End With
DoEvents
Next olItem
Set olReply = Nothing
Set olItem = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
End Sub

Bob Phillips
12-26-2019, 10:37 AM
So what is the question, what in the code doesn't work, or what extra do you want to do?

VBE313
12-26-2019, 10:40 AM
Hi xld, the following code below doesn't actually get the Subject Line. I need to set strTest to something that can actually grab the Subject Name.

strTest = myItem.Subject