• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

images in mime format message

How can I read the content-id of an image in a body message that is in mime format?

I can get the child/content type and sub-type i.e image/gif for instance plus the actual image content. I however need the CONTENT-ID for referencing purposes in displaying my final output.

Is there a method in the MIMEEntity class or anywhere else like getContentAsText() or getContentType() etc that can be used but to get the content-id instead?

Thx

0
jdembare
Asked:
jdembare
  • 2
  • 2
1 Solution
 
scottrmaCommented:
Use NotesMIMEEntity.ContentAsText property and then search the string returned by this property for content-id. For example, I use the following subroutine to concatenate all the header parts into a string called HeadersTextStr and all the content parts into a string called BodyTextStr:

(Declarations)
Dim HeadersTextStr As String
Dim BodyTextStr As String

Sub Concatenate
     
     Dim mime As NotesMIMEEntity
     Dim mime2 As NotesMIMEEntity
     
     s.ConvertMime = False
     HeadersTextStr = ""
     BodyTextStr = ""
     Set item = doc.GetFirstItem("Body")
     If Not (item.Type = MIME_PART) Then
          Exit Sub
     End If
     Set mime = item.GetMimeEntity
     
     While Not (mime Is Nothing)
          If Lcase$(mime.ContentType) = "text" Then
               HeadersTextStr = HeadersTextStr & mime.Headers
               BodyTextStr = BodyTextStr & mime.ContentAsText
          End If
          Set mime2 = mime.GetFirstChildEntity
          If mime2 Is Nothing Then
               Set mime2 = mime.GetNextSibling
          End If
          If mime2 Is Nothing Then
               Set mime2 = mime.GetParentEntity
               If Not (mime2 Is Nothing) Then
                    Set mime2 = mime2.GetNextSibling
               End If
          End If
          Set mime = mime2
     Wend
     
End Sub

I can then search the HeadersTextStr and BodyTextStr for whatever substrings I want:

Sub CheckMimeBody
     If Instr(1,BodyTextStr,"content-id",5) Then
          'Do some processing here
     End If
End Sub

Hope this helps.

Scott
0
 
jdembareAuthor Commented:
Thanks Scott worked fine however I realized that I left the setting part as well. I can't seem to then set the content-ID value of the new document I am creating. I tried setContentFromText(stream...) function but obviously this it is not recognised as a header setting.Part of my code is:

Stream stream = session.createStream();
MIMEEntity body = doc.createMIMEEEntity();
MIMEHeader header = body.createHeader("Content-Type");
header.setHeaderVal("multipart/mixed");
....
MIMEEntity child = body.createChildEntity();
stream.writeText(THE CONTENT-ID VALUE);
child.setContentFromText(stream,"image/gif",MIMEEntity.ENC_BASE64);

Obviously this isn't setting the header values coz when I read the headers of the new document it's returning:

Content-Transfer-Encoding: base64
Content-Type: image/gif

So I am still missing the content-id value in the header. How can i set this value maybe with something like setHeaderVal or what?

Thanks so much for the 1st pointer Scott.

jay


0
 
scottrmaCommented:
Hmmm, I don't recognize CreateStream() as a LotusScript function, is this a VB function? Although LotusScript is essentially derived from VB, the majority of my expertise is in LotusScript, so I am not sure how much I can help you here.

You may want to check out this technical article on how to connect a socket to a specific port on a server (such as Port 25 on an SMTP server), and then pass data back and forth through the socket:

http://www.codestore.info/A55692/store.nsf/unid/EPSD-587VVX

Although the main example given is written in Java, I am sure you could do the same thing in VB.

Regards,

Scott
0
 
jdembareAuthor Commented:
I see ur point but it's getting a bit hectic. stream is just a way of passing any content to the entities I suppose nothing much to it. the real question is can I set the child entity's header value - Content-ID? As u can see that the funciton setContentFromText(...) does set the Content-Type (2nd parameter); and encoding (3rd parameter); All I need is to then set as well the Content-ID.

Will see if I can fit the socket idea in my situation.

NB: code above in java but nothing different or unique to lotuscript.

regards,
jay
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now