Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook message headers

Status
Not open for further replies.

Crundy

Programmer
Jul 20, 2001
305
GB
Hi all,
I'm trying to get the message headers and body from an email. I am able to get the message body using:
Code:
    Set oOL = CreateObject("Outlook.Application")
    For x = 1 To oOL.ActiveExplorer.Selection.Count
        msgBody = oOL.ActiveExplorer.Selection.Item(x).Body
    Next
Which works fine, but I can't seem to find a way to get the headers in the same fashion (from within the loop above).

Can anyone help?

C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
 
If by header information, you mean the recipients and subject, the following code should help:

-----
Code:
    Dim objOutlook As Object
    Dim x As Integer
    Dim strBody As String, strTo As String, strCC As String, strBCC As String
    Dim strSubj As String
    
    Set objOutlook = CreateObject("Outlook.Application")
    With objOutlook.ActiveExplorer.Selection
        For x = 1 To .Count
            strTo = .Item(x).To
            strCC = .Item(x).CC
            strBCC = .Item(x).BCC
            strSubj = .Item(x).Subject
            strBody = .Item(x).Body
        Next
    End With
-----

Hope this helps.

Glen Appleton

VB.Net student.
 
Afraid the program I'm making is for reporting spam, so it needs to be the full headers. I've found out how to do it using CDO now, but thanks for replying.

C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top