%Net.POP3

25 views
Skip to first unread message

peter

unread,
Oct 31, 2007, 10:03:35 AM10/31/07
to intersystems...@info2.kinich.com
Hello,


I am using %Net.POP3 to receive mail from a mail server, but I am am having
some trouble trying retreiving the
contents of the message especially if it has attachments.
I fetch the message and see that it has a couple of parts, none of which is
the message the other parts are just the
attachments sent with the message.


Peter

Frank Schob

unread,
Nov 2, 2007, 3:13:25 AM11/2/07
to intersystems...@info2.kinich.com
Maybe this helps:

ClassMethod DumpMail(msg As %Net.MailMessage)
{
write !,"from="_msg.From
write !,"to="_msg.Headers.GetAt("to")
write !,"date="_msg.Date
write !,"subject="_msg.Subject
write !,"messagesize="_msg.MessageSize
d ..DumpMailAttachments(msg)
quit
}

ClassMethod DumpMailAttachments(msg As %Net.MailMessage, deep As %String
= "")
{
if msg.IsMultiPart {
for i=1:1:msg.Parts.Count() {
write !,"Dumping part "_deep_"."_i do
..DumpMailAttachments(msg.Parts.GetAt(i),deep_"."_i)
}
}
write !,"-- Content of <"_deep_"> --"
set index=""
w !,"> Header Parameter-Count: "_msg.Headers.Count()
for {
set value=msg.Headers.GetNext(.index)
quit:index=""
write !," Headers("_index_")="_value
}
if msg.IsBinary {
write !,"msg is binary, filename="_msg.FileName_"
filename="_msg.GetAttribute("content-disposition","filename")
} else {
write !,"Dumping text msg Filename="_msg.FileName_"
filename="_msg.GetAttribute("content-disposition","filename"),!
set stream=msg.TextData
do stream.Rewind()
set len=32763
while 'stream.AtEnd {
write stream.Read(.len)
}
}
write !,"-- End of <"_deep_"> --"
quit
}


Frank

Reply all
Reply to author
Forward
0 new messages