Consulting

Results 1 to 3 of 3

Thread: How can I store the Subject Line in a Reply Email as String?

  1. #1
    VBAX Regular
    Joined
    Mar 2019
    Posts
    15
    Location

    [SOLVED] How can I store the Subject Line in a Reply Email as String?

    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
    Last edited by VBE313; 12-26-2019 at 02:16 PM. Reason: Added code tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    So what is the question, what in the code doesn't work, or what extra do you want to do?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Mar 2019
    Posts
    15
    Location
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •