我已经获得了从我的收件箱文件夹中读取邮件的代码。但是,我无法从收件箱以外的文件夹中读取邮件。下面是我用于仅从我的收件箱中获取邮件的代码。
; display mail but don't delete from mailbox
testmail6 ;
new mailserver,status,err,mailMsg
set mailserver=##class(%Net.POP3).%New()
set mailserver.AttachDir="d:\attach\" ; need terminating \
set mailserver.StoreAttachToFile=1
write !,"Calling Connect"
set status=mailserver.Connect("Server.com","user","password")
if $$$ISERR(status) do DecomposeStatus^%apiOBJ(status,.err) write !,err(err),! quit
write !,"Calling Fetch to retrieve the oldest message on the server."
set status=mailserver.Fetch(1,.mailMsg,0)
if $$$ISERR(status) do DecomposeStatus^%apiOBJ(status,.err) write !,err(err),! quit
write !,"from="_mailMsg.From
write !,"to="_mailMsg.Headers.GetAt("to")
write !,"date="_mailMsg.Date
write !,"subject="_mailMsg.Subject
write !,"messagesize="_mailMsg.MessageSize
do DumpMessage(mailMsg)
quit