title: Insert string variable Into Text Body
body: <p>I would like to get two string variables to appear in the text body of an email.  I know we can define a body text and then have that body inserted as a whole.  I want to take it further and have two items inserted into the text, and appear not as VBA, but as actual names.  </p>
  
  <p>The two string variables are the first names of the first two recipients of an email, in this case named in the VBA as strTO and strTO1.  The current macro creates a reply and inserts them into the greeting.  I would also like to have them appear within the text body.  </p>
  
  <p>Example:  Recipient names are Tom Jones and Severus Snape, strTO and strTO1, respectively.  I insert them as shown here in the text:</p>
  
  <pre><code>strbody = "&lt;H2&gt;&lt;Font Face=calibri&gt;Good Day, &lt;/H2&gt;" &amp; strTO &amp; _
        "Please review your data below (link) and approve.&lt;br&gt;" &amp; _
        "Pleaes contact strTO1 if you have problems.&lt;br&gt;" &amp; _
        "&lt;A HREF=""http://www.google.com.htm""&gt;Click Here&lt;/A&gt;" &amp; _
        "&lt;br&gt;&lt;br&gt;&lt;B&gt;Thank you&lt;/B&gt;"
  </code></pre>
  
  <p><strong>What I want it to read as when I run the macro (bolded just for purposes of this post):</strong><br>
  Good Day, <strong>Tom</strong>.<br>
  Please review your data below (hyperlink) and approve.<br>
  Please contact <strong>Severus</strong> if you have problems.<br>
  (hyperlink that says "Click Here")<br>
  Thank you</p>
  
  <p><strong>What is happening now (Blank means just a blank space):</strong><br>
  Good Day <strong>BLANK</strong>,<br>
  Please review your data below (hyperlink that says "Click Here") and approve.<br>
  Please contact <strong>strTO1</strong> if you have problems.<br>
  Thank you</p>
  
  <p>I was hoping I could use tags of some sort to insert the strTO and the strTO1.  </p>
  
  <p>Below is the whole macro with the above code rolled in:</p>
  
  <pre><code>Sub AutoReply()
      Dim oMail As MailItem
      Dim oReply As MailItem
      Dim GreetTime As String
      Dim strbody As String
      Dim SigString As String
      Dim signature As String
      Dim strGreetNameAll As String
      Dim lastname As String
      Dim strgreetname As String
      Dim R As Long
      Dim text
      Dim strTo As String
      Dim strTo1 As String
  
      Select Case Application.ActiveWindow.Class
          Case olInspector
              Set oMail = ActiveInspector.CurrentItem
          Case olExplorer
              Set oMail = ActiveExplorer.Selection.Item(1)
      End Select
  
      strbody = "&lt;H2&gt;&lt;Font Face=calibri&gt;Good Day, &lt;/H2&gt;" &amp; &lt;strTo&gt; &amp; _
            "Please review your data below and approve.&lt;br&gt;" &amp; _
            "Please contact strTO1 if you have problems.&lt;br&gt;" &amp;
            "&lt;A HREF=""http://www.google.com.htm""&gt;Click Here&lt;/A&gt;" &amp; _
            "&lt;br&gt;&lt;br&gt;&lt;B&gt;Thank you&lt;/B&gt;"
  
      SigString = Environ("appdata") &amp; _
              "\Microsoft\Signatures\90 Days.htm"
  
      If Dir(SigString) &lt;&gt; "" Then
          strGreetName1 = Left$(oMail.SenderName, InStr(1, oMail.SenderName, " ") - 1)
          lastname = Right(oMail.SenderName, Len(oMail.SenderName) - InStr(1, oMail.SenderName, " "))              
  
          If Dir(SigString) &lt;&gt; "" Then
              signature = GetBoiler(SigString)
          Else
              signature = ""
          End If
  
          Set oReply = oMail.ReplyAll   
  
          Select Case Application.ActiveWindow.Class
          Case olInspector
              Set oMail = ActiveInspector.CurrentItem
          Case olExplorer
              Set oMail = ActiveExplorer.Selection.Item(1)
          End Select
  
          With oReply    
              For R = 1 To .recipients.Count
                  Debug.Print .recipients(R)
                  strgreetname = Left$(.recipients(R), InStr(1, .recipients(R), " "))
                  strGreetName2 = Left$(.recipients(2), InStr(1, .recipients(R), " "))
                  strGreetNameAll = strGreetNameAll &amp; strgreetname
                  strGreetNameAll1 = strgreetname
                  strTo = Left(strGreetNameAll, InStr(.recipients(R), " "))
                  strTo1 = Left(strGreetName2, InStr(1, .recipients(R), " "))
                  strTo = Left(.recipients(1), InStr(.recipients(1) &amp; " ", " ") - 1)    
  
                  If .recipients.Count &gt; 1 Then
                      strTo1 = Left(.recipients(2), InStr(.recipients(2) &amp; " ", " ") - 1)
                  Else
                      strTo1 = ""
                  End If
              Next R
  
              Debug.Print strGreetNameAll
  
              strGreetNameAll = Left(strGreetNameAll, Len(strGreetNameAll) - 1)
  
              Debug.Print strGreetNameAll
  
              .HTMLBody = "&lt;Font Face=calibri&gt;Dear " &amp; strTo &amp; " and " &amp; strTo1 &amp; ", " &amp; strbody &amp; "&lt;br&gt;" &amp; signature
              .Display
          End With
      End If
  End Sub
  </code></pre>