Accessing email Content-Type

Accessing email Content-Type

Post by m. lamphi » Tue, 18 Feb 2003 11:51:23



I am using Notes R5.

I am trying to access the Content-Type for email messages. If I open
up an email message and then open up Document Properties, the
Content-Type and Content-Transfer-Encoding headers, I find they do not
have their own fields, rather they appear as the first few lines in
the "Body" field.

OK fine, so using Lotus script I get the body field from the document
just using

Set rt = doc.GetFirstItem("body")
string = rt.GetFormattedText(True,0)

But when I look for the characters "Content-Type" in the string, they
are not there. Furthermore, when I go back to the email and check
Document Properties again, now first few lines of the body that showed
the Content-Type and Conten-Transfer-Encoding headers have
disappeared.......

what am I doing wrong, and how do I access Content-Type?

Actually, I am just trying to recreate the original email headers so
that I can send off spam complaints. Is there a simple way to assemble
or retrieve the original headers for an email in Notes?

thanks,
Marc

 
 
 

Accessing email Content-Type

Post by m. lamphi » Tue, 18 Feb 2003 18:41:24


OK.... I got it now, there is a separate class: NotesMIMEEntity class
that needs to be accessed.

Also, accessing an item that is a MIMEentity type as if it was a text
field, or a rich text field, results in it being converted to rich
text, thus erasing much of the MIMEEntity properties. This is why the
Content-Type information was diappearing each time I ran my script. To
prevent this I needed to use:

s.ConvertMime=false

to prevent conversion in RT.

The other problem is that some of these header fields appear as
duplicate items. As I understand it, the only way to access
information is to read and then remove the field; this allows the next
duplicate item to be accessed.

Also, how does one access a field with a "$" in front of it? I get an
error each time I try to do directly (I resorted to scrolling through
all of the items in the document until matching a string within the
item name, e.g. the program finds $Message by scrolling through
looking for substring "Message")

Once it is finished I will set up to automatically forward spam mail
to SpamCop

*** script to recreate email headers (still in progress)***

Sub Initialize
        Dim ws As New NotesUIWorkspace
        Dim s As New NotesSession
        s.ConvertMime = False
        Dim db As NotesDatabase
        Dim uidoc As NotesUIDocument
        Dim doc As NotesDocument
        Dim doc2 As NotesDocument
        Dim item As NotesItem

[a bunch of uninteresting stuff skipped]

%REM
retrieving values in duplicate items by sequentially removing them
%END REM

        Dim rec As String
        rec = ""
        Set item = doc.GetFirstItem("Received")
        Do
                Msgbox item.text
                rec = rec & "Received:" & item.text & Chr(10)
                Call item.remove
                Set item = doc.GetFirstItem("Received")
        Loop Until item Is Nothing

        doc2.ReceivedD = rec    
        doc2.FromD = doc.From(0)
        doc2.ToD = doc.SendTo(0)
        doc2.SubjectD = doc.Subject(0)
        etc.

%REM
get mime headers. Actually it turns out that for a multi-part message,
the body item is duplicated. So, the script below must be modified to
sequentially read each duplicate item by removing the previous one (as
shown above for the duplicated "received" fields)
%END REM

        Dim body As NotesItem
        Dim mime As NotesMIMEEntity
        Dim m As String
        Set body = doc.GetFirstItem("Body")
        If body.type = MIME_PART Then
                Set mime = body.GetMimeEntity
                doc2.Mime_D = mime.Headers    ! gets content-type headers
                doc2.bodyD = mime.ContentAsText ! gets body of message
        End If

%rem
original email with full headers will be recreated in doc2
%end rem

        Call doc2.save(True, False, False)

End Sub

 
 
 

1. mail attachment content-type

hi,

I'm having trouble opening mime attachments because the attachment
content type is not set correctly, its set to octet-stream when it
should be application/pdf. it is received as a .eml file and I have to
open Outlook Express to see the attachment as a .pdf, anyone know a
work-around in notes configuration that would allow me launch these
attachments from notes, until the person sending the email fixes
attachment content-type problem?

thanks in advance
tony

2. Classic memory.

3. Mail problem: Content-Type: multipart/report

4. Problem with SNMP

5. SMTP And Mime Content-Type

6. Trouble with Win 2000

7. MAIL: How to change MIME Content-Type field

8. Messenger 4.7 and 5.x - Same Time?

9. How do you send content-type ????

10. STMP Content Type Error

11. Content type in Domino

12. Email access vs Calendar access