#INCLUDE "TOTVS.CH"
#DEFINE EMAIL_ACCOUNT 'p10teste'
#DEFINE EMAIL_PASSWORD '123'
#DEFINE EMAIL_POPSERVER 'pop3.provedor.com.br'
#DEFINE EMAIL_SMTPSERVER 'smtp.provedor.com.br'
User Function mail004()
Local oMail := tMailManager():NEW()
Local nRet := 0
Local nNumMsg := 0
oMail:Init( EMAIL_POPSERVER, EMAIL_SMTPSERVER, EMAIL_ACCOUNT, EMAIL_PASSWORD )
nret := oMail:PopConnect()
If nRet == 0
conout( "Open Successful" )
Else
conout( nret )
conout( oMail:GetErrorString( nret ) )
Endif
nRet := oMail:GetNumMsgs( @nNumMsg )
If nRet == 0
conout( "Count Successful" )
conout( nNumMsg )
Else
conout( nret )
conout( oMail:GetErrorString( nret ) )
Endif
If nNumMsg > 0
nRet := oMail:DeleteMsg( 1 )
If nRet == 0
conout( "Delete Successful" )
conout( nNumMsg )
Else
conout( nret )
conout( oMail:GetErrorString( nret ) )
Endif
Else
conout( "não há mensagens para deletar" )
Endif
oMail:PopDisConnect()
Return |