Autor Thema: Mime Type eines Attachments erkennen  (Gelesen 5755 mal)

y20frank

  • Gast
Mime Type eines Attachments erkennen
« am: 26.03.06 - 19:57:58 »
Hallo zusammen,

gibt es die Möglichkeit, das mime-type eines Attachments aus einem Notes-Dokument auszulesen?

Also, in einer Datenbank (R6.5'er'er Clients) ist ein RTF 'Body', dort ist immer nur ein Datei-Anhang drin. Dieser kann von unterschiedlichem Typ sein (z. B. wie application/msexcel   *.xls *.xla Microsoft Excel Dateien, image/gif *.gif GIF-Dateien, application/msword *.doc *.dot Microsoft Word Dateien ... usw)

Gibt es nun - per Script oder Formel - die Möglichkeit, an diese Informationen des Anhanges heranzukommen?

Danke und Gruß
Frank


« Letzte Änderung: 27.03.06 - 21:14:39 von y20frank »

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
Re: Mime Type eines Attachments erkennen
« Antwort #1 am: 27.03.06 - 07:42:45 »
Schau dir mal die Klasse NotesMimeEntity in der Hilfe an.
Das könnte helfen
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

y20frank

  • Gast
Re: Mime Type eines Attachments erkennen
« Antwort #2 am: 27.03.06 - 08:42:12 »
Danke dir, habe das auch schon gefunden, komme damit (siehe Script aus der Hilfe nachstehend) aber nicht weiter. Brauche den mime-type des Attachments.

Code
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim mime As NotesMIMEEntity
Dim m As String
Set db = s.CurrentDatabase
s.ConvertMIME = False ' Do not convert MIME to rich text
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not(doc Is Nothing)
Set mime = doc.GetMIMEEntity
If Not(mime Is Nothing) Then     
Messagebox mime.ContentAsText,, _
doc.GetItemValue("Sunject")(0)
Else
Messagebox "Not MIME",, _
doc.GetItemValue("Subject")(0)
End If
Set doc = dc.GetNextDocument(doc)
Wend
s.ConvertMIME = True ' Restore conversion
End Sub
« Letzte Änderung: 27.03.06 - 21:14:15 von y20frank »

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
Re: Mime Type eines Attachments erkennen
« Antwort #3 am: 27.03.06 - 23:25:13 »
Ich müßte in der Firma noch code haben, wo ich durch alle in einer Email benutzten Mimes iteriere. Viellicht hilft das irgendwie weiter. Schau morgen mal nach.

gruß Axel
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
Re: Mime Type eines Attachments erkennen
« Antwort #4 am: 28.03.06 - 11:53:34 »
weiss nicht obs hilft:
Das in Initialize eines Agenten in der Mail-db.

-> Auswahl im Menü Aktionen
-> Ziel: Alle ausgewählten Dokumente
Dokumente anhaken und dann Agenten per Menü starten.
Vielleicht kannst du das irgendwie nutzen. 

Code
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim mime As NotesMIMEEntity
Dim child As NotesMIMEEntity
Dim m As String
Set db = s.CurrentDatabase
s.ConvertMIME = False
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
Dim countChild As Integer
While Not(doc Is Nothing)
Msgbox "startMail mail->" & doc.subject(0)
Set mime = doc.GetMIMEEntity
If Not(mime Is Nothing) Then
If mime.ContentType = "multipart" Then
If mime.Preamble = "" Then
p$ = "No preamble"
Else
p$ = mime.Preamble
End If
Messagebox p$,, "preamble of:" & doc.GetItemValue("Subject")(0)
Set child = mime.GetFirstChildEntity
countChild = 0
While Not(child Is Nothing)
countChild = countChild + 1
m = "Content type:" & Chr(9) & _
child.ContentType & Chr(13) & _
"Content subtype:" & Chr(9) & _
child.ContentSubType & Chr(13) & _
"Character set:" & Chr(9) & _
child.Charset & Chr(13) & _
"Encoding:" & Chr(9) & Chr(9) & _
child.Encoding
Messagebox m,, "child: (" & Cstr(countChild) & " in Mail->" & doc.subject(0)
Messagebox child.Headers,, "Headers von child: (" & Cstr(countChild) & " in Mail->" & doc.subject(0)
Messagebox child.ContentAsText,, "child: (" & Cstr(countChild) & " in Mail->" & doc.subject(0)
Set child = child.GetNextSibling
Wend
Else ' if not multipart
m = "Content type:" & Chr(9) & _
mime.ContentType & Chr(13) & _
"Content subtype:" & Chr(9) & _
mime.ContentSubType & Chr(13) & _
"Character set:" & Chr(9) & _
mime.Charset & Chr(13) & _
"Encoding:" & Chr(9) & Chr(9) & _
mime.Encoding
Messagebox m,, "main of mail:" & doc.GetItemValue("Subject")(0)
Messagebox mime.Headers,, "Headers of main of mail:" & doc.GetItemValue("Subject")(0)
Messagebox mime.ContentAsText,, _
"main of mail:" & doc.GetItemValue("Subject")(0)
End If
Else ' if not MIME
Messagebox "Not MIME",, _
doc.GetItemValue("Subject")(0)
End If
Msgbox "END mail->" & doc.subject(0)
Set doc = dc.GetNextDocument(doc)
Wend
s.ConvertMIME = True ' Restore conversion
End Sub
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

y20frank

  • Gast
Re: Mime Type eines Attachments erkennen
« Antwort #5 am: 28.03.06 - 16:54:26 »
+++ Update 08.04.2006 +++
HMPF, hat leider auch nicht funktioniert. Das NotesDoc hat einen Anhang, aber der MimeType wird noch immer nicht zurückgegeben...
+++ Update 08.04.2006 +++

Danke Axel, das werde ich gleich morgen ausprobieren!  :D

Besten Gruß
Frank
« Letzte Änderung: 08.04.06 - 20:46:28 von y20frank »

Offline magic_halli

  • Senior Mitglied
  • ****
  • Beiträge: 348
  • Geschlecht: Männlich
Re: Mime Type eines Attachments erkennen
« Antwort #6 am: 17.02.09 - 14:49:05 »
Hi,

aus aktuellem Anlass greife ich dieses Thema nochmal auf.
Ich habe den Code von Pitiyankee mal implementiert, um an Attachments zu gelangen, die im MIME-Type im Body enthalten sind... funzt erstmal, d.h. ich kann die entsprechenden Infos auslesen!

Mich würde aber interessieren, ob ich solch ein Attachment auch auf Platte speichern kann!?!
"Normale" Attachments speichere ich bspw. so weg:
Zitat
   Set attachment = docMail.GetFirstItem("Body")
   ' TempDir des Win-Benutzers
   tempdir = Environ("temp")
   Dim fileArrayString As String
   
   If ( docMail.HasEmbedded ) Then
      If ( attachment.Type = RICHTEXT ) Then
         Forall o In attachment.EmbeddedObjects
            If ( o.Type = EMBED_ATTACHMENT ) Then
               ' Attachment in TempVerzeichnis des Nutzers speichern
               filepath = tempdir & "\" & o.Source
               Call o.ExtractFile( filepath )
               ' String zusammensetzen (in Java splitten)
               fileArrayString = fileArrayString + filepath + ";"
            End If
         End Forall
      End If
      ' Rückgabewert
      getAttachments = fileArrayString
   End If
Mittels der Zeile 'Call o.ExtractFile( filepath )' wird das Attachment unter einen Pfad auf HDD gespeichert.

Kann ich auch irgendwie das File aus dem MIME-Type auf Platte speichern? (siehe Code von Pitiyankee)

Danke und Gruß

Rico.
Lotus Notes 8.0.2

Offline magic_halli

  • Senior Mitglied
  • ****
  • Beiträge: 348
  • Geschlecht: Männlich
Re: Mime Type eines Attachments erkennen
« Antwort #7 am: 17.02.09 - 16:13:59 »
Hi,

ich habe eine Möglichkeit gefunden, um die "MIME-Files" auf Platte zu speichern:
Code
Dim session As New NotesSession
Dim mime As NotesMIMEEntity
Dim child As NotesMIMEEntity
Dim stream As NotesStream
Dim pathname As String
Dim countChild As Integer
session.ConvertMIME = False
Msgbox "startMail mail->" & docMail.subject(0)
Set mime = docMail.GetMIMEEntity
If Not(mime Is Nothing) Then
Set child = mime.GetFirstChildEntity
countChild = 0
While Not(child Is Nothing)
countChild = countChild + 1
'GIF speichern
If child.ContentType = "image" And child.ContentSubtype = "gif" Then
Set stream = session.CreateStream
pathname = "D:\temp\mime\mimeimage" & countChild &".gif"
If Not stream.Open(pathname, "binary") Then
Messagebox pathname,, "Open failed"
'Goto ExitSub
End If
Call child.GetContentAsBytes(stream)
Call stream.Close()
Else
Messagebox "Not GIF",, docMail.GetItemValue("Subject")(0)
End If
' JPEG speichern
If child.ContentType = "image" And child.ContentSubtype = "jpeg" Then
Set stream = session.CreateStream
pathname = "D:\temp\mime\mimeimage" & countChild &".jpeg"
If Not stream.Open(pathname, "binary") Then
Messagebox pathname,, "Open failed"
'Goto ExitSub
End If
Call child.GetContentAsBytes(stream)
Call stream.Close()
Else
Messagebox "Not JPEG",, docMail.GetItemValue("Subject")(0)
End If
Set child = child.GetNextSibling
Wend
Else ' if not MIME
Messagebox "Not MIME",, _
docMail.GetItemValue("Subject")(0)
End If
Msgbox "END mail->" & docMail.subject(0)
session.ConvertMIME = True ' Restore conversion
So klappt das schonmal mit gif´s und jpeg´s bei mir... werde diesen Code noch etwas ausbauen und dann so nutzen.
Wenn jemand zufällig ein grober Schnitzer/Anregungen o.ä. hierzu auffallen sollten, dann immer raus damit.

Gruß

Rico.
Lotus Notes 8.0.2

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz