home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "DemoCode"
- Option Explicit
-
- ' Bare bones of a roll-your-own forwarding mechanism
- Sub DemoA()
- Dim olMsg1 As MailItem, olMsg2 As MailItem
- If ActiveExplorer.Selection.Count <> 1 Then Exit Sub
- Set olMsg1 = ActiveExplorer.Selection.Item(1)
- Set olMsg2 = Application.CreateItem(olMailItem)
- With olMsg2
- .Subject = "Re: " + olMsg1.Subject
- .Body = "From: " + olMsg1.SenderName + vbNewLine
- .Body = .Body + "To: " + olMsg1.To + vbNewLine
- .Body = .Body + vbNewLine + olMsg1.Body
- .Display
- End With
- End Sub
-
- ' Basic version of Forward method followed by manipulation of the Body property
- Sub DemoB()
- Dim olMsg As MailItem
- Dim i1 As Integer, i2 As Integer
-
- If ActiveExplorer.Selection.Count <> 1 Then Exit Sub
- Set olMsg = ActiveExplorer.Selection.Item(1).Forward
-
- With olMsg
- i1 = InStr(.Body, "[mailto:")
- i2 = InStr(i1 + 7, .Body, vbNewLine)
- .Body = Left$(.Body, i1 - 1) + Right$(.Body, Len(.Body) - i2 + 1)
-
- i1 = InStr(.Body, "From:")
- i2 = InStr(i1 + 5, .Body, vbNewLine)
- i1 = InStr(i1 + 5, .Body, "@")
- If i1 > 0 And i1 < i2 Then
- .Body = Left$(.Body, i1 - 1) + Right$(.Body, (Len(.Body) - i2) + 1)
- End If
-
- i1 = InStr(.Body, "To:")
- i2 = InStr(i1 + 3, .Body, vbNewLine)
-
- .Body = Left$(.Body, i1 + 2) + " Steve" + Right$(.Body, Len(.Body) - i2 + 1)
-
- .Display
- End With
- End Sub
-
- ' Improved version tries to deal intelligently with HTML mail
- Sub DemoC()
- Dim olMsg As MailItem
- Dim strBody As String
- Dim i1 As Integer, i2 As Integer
- Dim strNewLine As String
-
- If ActiveExplorer.Selection.Count <> 1 Then Exit Sub
- Set olMsg = ActiveExplorer.Selection.Item(1).Forward
-
- If olMsg.HTMLBody <> "" Then
- strBody = olMsg.HTMLBody
- strNewLine = "<BR>"
- Else
- strBody = olMsg.Body
- strNewLine = vbNewLine
- End If
- '''''''''''''''''''''''''''''''''''''''''''''''
-
- i1 = InStr(strBody, "[mailto:")
- i2 = InStr(i1 + 7, strBody, strNewLine)
- strBody = Left$(strBody, i1 - 1) + Right$(strBody, Len(strBody) - i2 + 1)
-
- i1 = InStr(strBody, "From:")
- i2 = InStr(i1 + 5, strBody, strNewLine)
- i1 = InStr(i1 + 5, strBody, "@")
- If i1 > 0 And i1 < i2 Then
- strBody = Left$(strBody, i1 - 1) + Right$(strBody, (Len(strBody) - i2 + 1))
- End If
-
- i1 = InStr(strBody, "To:")
- i2 = InStr(i1 + 3, strBody, strNewLine)
-
- strBody = Left$(strBody, i1 + 2) + " Steve" + Right$(strBody, Len(strBody) - i2 + 1)
-
- '''''''''''''''''''''''''''''''''''''''''''''''
- If olMsg.HTMLBody <> "" Then
- olMsg.HTMLBody = strBody
- Else
- olMsg.Body = strBody
- End If
-
- olMsg.Display
- End Sub
-
-