JUDSON ROSA Posted March 3, 2018 Report Share Posted March 3, 2018 Bom dia , amigos uso a rotina abaixo para envio de emails que peguei aqui no forum , mais de um tempo pra ca nao funciona mais , a varios meses venho tentando colocar ela pra funcionar e nada , ja pesquisei aqui mais nada resolve . Vou postar aqui a rotina , se não tiver uma solução vou desistir dessa ja perdi muito tempo , vi aqui tbm q o gilme postou a dica comprar um componente da http://www.marshallsoft.com/email-component-library.htm , se alguem usar componentes de outras empresas aceito sugestões. desde ja agradeço. estou usando windows 7 prof Function fSendMail ( cProvedor, cFrom, cTo, cSubject, cBody, cAttach, cBCC, cUser, cPass ) ****************** Private oCfg, oMsg, oError, nEle, cToken, ; aAttach := {}, ; lAuth := ! Empty( cUser ) .and. ! Empty( cPass ), ; nSendOpt := 2 // send using: 1 = pickup folder 2 = port 3 = remote mail server * por por * ta ta * Nome Provedor endereço pop3 endereço smtp Autenticacao smtp pop ssl * // 465 Private aProvedor := { {"UOL (Universo On-Line)" , 'pop3.uol.com.br' , 'smtps.uol.com.br' , .t. , 587,995,.t.},; {"Terra" , 'pop.terra.com.br' , 'smtp.terra.com.br' , .t. , 587,110,.f.},; {"IG (Internet Generation)" , 'pop.ig.com.br' , 'smtp.ig.com.br' , .t. , 465,995,.t.},; // ok {"iBest" , 'pop.ibest.com.br' , 'smtp.ibest.com.br' , .t. , 465,995,.t.},; // {"iTelefônica" , 'pop.itelefonica.com.br' , 'smtp.itelefonica.com.br' , .t. , 025,110,.f.},; {"Gmail (Google Mail)" , 'pop.gmail.com.br' , 'smtp.gmail.com.br' , .t. , 465,995,.t.},; // {"Yahoo" , 'pop.mail.yahoo.com.br' , 'smtp.mail.yahoo.com.br' , .t. , 587,995,.F.},; // ok {"Hotmail" , 'pop3.live.com' , 'smtp.live.com' , .t. , 25,995,.T.},; // ok {"BOL (Brasil On-Line)" , 'pop3.bol.com.br' , 'smtps.bol.com.br' , .t. , 465,995,.T.} } // // {"Fotosombra" , 'pop.fotosombra.com.br' , 'smtp.fotosombra.com.br' , .t. , 025,110,.f.} } Default cSubject := "", ; cBody := "" * nPosicao := ASCAN(aProvedor, {|a| Upper(AllTrim(a[1])) = Upper(AllTrim(cProvedor)) } ) * nPort := aProvedor[nPosicao, 5] lAuth := aProvedor[nPosicao, 4] cMailServer := aProvedor[nPosicao, 3] cSSL := aProvedor[nPosicao, 7] * If "GMAIL.COM" $ Upper( cMailServer ) .and. ( Empty( cUser ) .or. Empty( cPass ) ) MsgStop( "Com GMail são requeridos nome do usuario e senha", "Atenção" ) Return .f. EndIf CursorWait() nEle := 1 lRet := .f. While ! Empty( cToken := StrToken( cAttach, nEle++, "," ) ) AAdd( aAttach, AllTrim(cToken) ) EndDo ? ":Value = AllTrim(cMailServer)" , AllTrim(cMailServer) ? ":Value = nPort " , nPort ? ":Value = nSendOpt " , nSendOpt ? ":Value = lAuth " , lAuth ? ":Value = cSSL " , cSSL ? ":Value = Alltrim(cUser)" , Alltrim(cUser) ? ":Value = AllTrim(cPass)" , AllTrim(cPass) Try oCfg := CREATEOBJECT( "CDO.Configuration" ) WITH OBJECT oCfg:Fields :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value = AllTrim(cMailServer) :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value = nPort :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value = nSendOpt :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = lAuth :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value = 1 // cSSL :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value = Alltrim(cUser) :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value = AllTrim(cPass) :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value = 30 :Update() END WITH CATCH oError MsgInfo( "Não Foi possível Enviar o e-Mail!" +CRLF+ ; "Error: " + Transform(oError:GenCode, nil) + ";" +CRLF+ ; "SubC: " + Transform(oError:SubCode, nil) + ";" +CRLF+ ; "OSCode: " + Transform(oError:OsCode, nil) + ";" +CRLF+ ; "SubSystem: " + Transform(oError:SubSystem, nil) + ";" +CRLF+ ; "Mensaje: " + oError:Description, "CDO.Configuração" ) END TRY oMsg := CreateObject( "CDO.Message" ) With Object oMsg :Configuration = oCfg :From = AllTrim(cFrom) :To = AllTrim(cTo) :Subject = AllTrim(cSubject) :MDNRequested = .F. :TextBody = AllTrim(cBody) For nEle := 1 To Len( aAttach ) :AddAttachment = AllTrim(aAttach[ nEle ]) Next If ! Empty( cBCC ) :BCC = AllTrim(cBCC) EndIf ? "send" :Send() End With MsgInfo("Mensagem Enviada com Sucesso!","Atençao") lRet := .t. Catch oError CursorArrow() MsgStop( "Não foi possível enviar a mensagem para "+AllTrim(cTo) + CRLF + ; "Error: " + cValToChar( oError:GenCode) + CRLF + ; "SubC: " + cValToChar( oError:SubCode ) + CRLF + ; "OSCode: " + cValToChar( oError:OsCode ) + CRLF + ; "SubSystem: " + cValToChar( oError:SubSystem ) + CRLF + ; "Mensagem: " + oError:Description ) lRet := .f. End Try oCfg := Nil oMsg := Nil If lRet MsgInfo("Email Enviado com Sucesso","Email") End CursorArrow() Return ( lRet ) ****************************** o erro e sempre o mesmo . error: 1001 subc: 3 oscode: 0 subsystem: cdo.message mensagem: disp_e_membernotfound Quote Link to comment Share on other sites More sharing options...
sistem Posted March 5, 2018 Report Share Posted March 5, 2018 hudson, poderia usar o CDOSYS, veja: em vbscript (salvar com bloco de notas ex: email.vbs) o código abaixo: sendmail() Sub sendmail() Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true 'Ativar autenticação SSL .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 '1 habilita a autenticação básica, '2 permite autenticação NTLM, '0 desativa a autenticação .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "teste@gmail.com" 'email/nome da conta ex.com gmail .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30 'tempo limite de conexão .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "SuaSenha" 'senha remetente .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'servidor smtp ex.com gmail 'yahoo smtp.mail.yahoo.com 465 *Abilitar a opção "permitir apps que usam métodos de acesso menos seguros" na sua conta site so yahoo 'outlook smtp.live.com, outlook.office365.com, smtp-mail.outlook.com 587, 25 'gmail smtp.gmail.com 465 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '2-enviar usando porta '1-enviar usando servidor smtp local '3-enviar usando exchange server .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'porta smtp a ser habilitada ex. com gmail .Update End With With iMsg Set .Configuration = iConf .To = "teste@gmail.com" 'email destinatário .CC = "" 'carbon copy .BCC = "" 'blind carbon copy .From = "teste@gmail.com" 'email remetente ex. com gmail .Subject = "email usando vbscript" 'assunto .TextBody = "mensagem do email" 'mensagem '.HtmlBody = "<html> <head><meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8""></head><body></body></html>" 'para envio de mensagem no formato html .AddAttachment "e:\teste1.txt" 'anexo 1 .AddAttachment "e:\teste2.txt" 'anexo 2 ... .. . .Send MsgBox "ok" End With End Sub execute assim: cscript //nologo email.vbs ou 2 click mesmo em fivewin ficaria: #include "fivewin.ch" Function Main() local oCfg, oError, oMsg, lRet:= .f. TRY oCfg := CREATEOBJECT( "CDO.Configuration" ) WITH OBJECT oCfg:Fields :Item( "http://schemas.microsoft.com/cdo/configuration/cdoBasic" ):Value := 1 :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .t. :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .t. :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := "smtp.gmail.com" // ex. com gmail :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 465 // ex. com gmail :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := "SeuEMail@gmail.com" // ex.com gmail :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := "SuaSenha" :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" ):Value := 30 // :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusetls" ):Value := .t. // :Item( "http://schemas.microsoft.com/cdo/configuration/cdoSendTLS" ):Value := .t. // :Item( "http://schemas.microsoft.com/cdo/configuration/HtmlBody = "<html> <head><meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8""></head><body>TESTE</body></html>" :Update() END WITH CATCH oError ? "Error: " + Transform(oError:GenCode, nil) + ";" +CRLF+ ; "SubC: " + Transform(oError:SubCode, nil) + ";" +CRLF+ ; "OSCode: " + Transform(oError:OsCode, nil) + ";" +CRLF+ ; "SubSystem: " + Transform(oError:SubSystem, nil) + ";" +CRLF+ ; "Mensagem: " + oError:Description END TRY oMsg := CREATEOBJECT ( "CDO.Message" ) WITH OBJECT oMsg :Configuration = oCfg :From = "EmailRemetente@gmail.com" // ex. com gmail :To = "EmeilDdestino@gmail.com" // ex. com gmail :Subject = "Assunto do email" :TextBody = "SuaMsg" :AddAttachment = "e:\teste1.txt" :AddAttachment = "e:\teste2.txt" :Send() END WITH lRet := .t. CATCH oError ? "Error: " + Transform(oError:GenCode, nil) + ";" +CRLF+ ; "SubC: " + Transform(oError:SubCode, nil) + ";" +CRLF+ ; "OSCode: " + Transform(oError:OsCode, nil) + ";" +CRLF+ ; "SubSystem: " + Transform(oError:SubSystem, nil) + ";" +CRLF+ ; "Mensagem: " + oError:Description END If lRet ? "ok" Endif Return nil agora a noticia ruim eh que nao consegui enviar emails com servicos da microsoft, tipo: windowslive.com hotmail.com outlook.com gmail, yahoo... trabalha bem Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 bom dia , mais e dessa forma q estou usando , eu nao consigo mandar e de nenhum rsrs. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted March 5, 2018 Report Share Posted March 5, 2018 https://www.4shared.com/zip/9wQ0A3UHce/RMAIL.html Quote Link to comment Share on other sites More sharing options...
kapiaba Posted March 5, 2018 Report Share Posted March 5, 2018 Qual é provedor que você está usando? UOL? Se for, tente com smtps.uol.com.br ou use o gmail.com ou yahoo.com, uso o gmail.com e yahoo.com e funciona de boas. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted March 5, 2018 Report Share Posted March 5, 2018 { {"@hotmail.com", "smtp.live.com", 587, .T. }, ; {"@yahoo.com", "smtp.mail.yahoo.com", 465, .T. }, ; {"@gmail.com", "smtp.gmail.com", 465, .T. }, ; {"@outlook.com.", "smtp-mail.outlook.com", 465, .T. }, ; {"@uol.com.br", "smtps.uol.com.br", 465, .T. }, ; {"@bol.com.br", "smtps.bol.com.br", 587, .F. }, ; {"@terra.com.br", "smtp.terra.com.br", 465, .T. }, ; {"@ig.com.br", "smtp.ig.com.br", 465, .T. }, ; {"@ibest.com.br", "smtp.ibest.com.br", 465, .T. } } Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 https://www.4shared.com/zip/9wQ0A3UHce/RMAIL.html bom dia , KAPI vou dar uma olhada , e te falo , valeu . . Quote Link to comment Share on other sites More sharing options...
kapiaba Posted March 5, 2018 Report Share Posted March 5, 2018 O ideal, é que você crie um configurador tipo o do Windows Live Mail, para que quando haja o que hajá(kkkk) o uçuário possa modificar a gosto o provedor, smtp, senha, etc. Tipo assim: Abs. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted March 5, 2018 Report Share Posted March 5, 2018 Amarrando: Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 KAPI , fiz todos os testes e nada , obrigado ai , infelizmente vou desistir . Alguem me indica o componente PAGO , pois nao aguento mais ( kkk ) , preciso disso no nosso sistema agradeço a todos. Quote Link to comment Share on other sites More sharing options...
Marca Posted March 5, 2018 Report Share Posted March 5, 2018 Judson. Eu tive o mesmo problema com o Cdo em um Server2003 Hora funcionava hora não Baixei na net SwithMail.exe q. é Free e consegui enviar utilizando ele. Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 opa , vou testar Marca , to cansado de testar e nao dar certo . obrigado Quote Link to comment Share on other sites More sharing options...
Marca Posted March 5, 2018 Report Share Posted March 5, 2018 opa , vou testar Marca , to cansado de testar e nao dar certo . obrigado Você já tentou utilizando o Outlook ou algo neste sentido somente pra ver se o problema não esta na sua conta de email ? Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 como assim ?? acabei de fazer teste com o IG de uma amigo programador ( helio ) q ele me garante q esta rotina funciona com ele , e mesmo assim tbm nao funcionou . entao ja testei com o yahoo , gmail e ig e nada . Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 Pessoal no apagar das luzes , testei com uma conta do hotmail.com e nao e q FUNCIONOU . agora pq sera que com os outros nao funcionam vou criar uma conta entao no hotmail so para ser meu provedor de emails , so sendo assim . Quote Link to comment Share on other sites More sharing options...
sistem Posted March 5, 2018 Report Share Posted March 5, 2018 Judson hotmail funcionou com que? cdosys? se for poderia postar o codigo Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 sim , so funcionou com hotmail. peguei uma conta aqui do meu filho e testei e mandou blz o email. o fonte e o mesmo que tem por aqui , mais vou postar : {"Hotmail" , 'pop3.live.com' , 'smtp.live.com' , .t. , 25,995,.T.},; // ok Function fSendMail ( cProvedor, cFrom, cTo, cSubject, cBody, cAttach, cBCC, cUser, cPass ) ****************** Private oCfg, oMsg, oError, nEle, cToken, ; aAttach := {}, ; lAuth := ! Empty( cUser ) .and. ! Empty( cPass ), ; nSendOpt := 2 // send using: 1 = pickup folder 2 = port 3 = remote mail server * por por * ta ta * Nome Provedor endereço pop3 endereço smtp Autenticacao smtp pop ssl * // 465 Private aProvedor := { {"UOL (Universo On-Line)" , 'pop3.uol.com.br' , 'smtps.uol.com.br' , .t. , 587,995,.t.},; {"Terra" , 'pop.terra.com.br' , 'smtp.terra.com.br' , .t. , 587,110,.f.},; {"IG (Internet Generation)" , 'pop3.ig.com.br' , 'smtp.ig.com.br' , .t. , 465,995,.t.},; // ok {"iBest" , 'pop.ibest.com.br' , 'smtp.ibest.com.br' , .t. , 465,995,.t.},; // {"iTelefônica" , 'pop.itelefonica.com.br' , 'smtp.itelefonica.com.br' , .t. , 025,110,.f.},; {"Gmail (Google Mail)" , 'pop.gmail.com.br' , 'smtp.gmail.com.br' , .t. , 465,995,.t.},; // {"Yahoo" , 'pop.mail.yahoo.com.br' , 'smtp.mail.yahoo.com.br' , .t. , 587,995,.t.},; // ok {"Hotmail" , 'pop3.live.com' , 'smtp.live.com' , .t. , 25,995,.T.},; // ok {"BOL (Brasil On-Line)" , 'pop3.bol.com.br' , 'smtps.bol.com.br' , .t. , 465,995,.T.}} // {"Fotosombra" , 'pop.fotosombra.com.br' , 'smtp.fotosombra.com.br' , .t. , 025,110,.f.} } Default cSubject := "", ; cBody := "" * nPosicao := ASCAN(aProvedor, {|a| Upper(AllTrim(a[1])) = Upper(AllTrim(cProvedor)) } ) * nPort := aProvedor[nPosicao, 5] lAuth := aProvedor[nPosicao, 4] cMailServer := aProvedor[nPosicao, 3] cSSL := aProvedor[nPosicao, 7] * If "GMAIL.COM" $ Upper( cMailServer ) .and. ( Empty( cUser ) .or. Empty( cPass ) ) MsgStop( "Com GMail são requeridos nome do usuario e senha", "Atenção" ) Return .f. EndIf CursorWait() nEle := 1 lRet := .f. While ! Empty( cToken := StrToken( cAttach, nEle++, "," ) ) AAdd( aAttach, AllTrim(cToken) ) EndDo ? ":Value = AllTrim(cMailServer)" , AllTrim(cMailServer) ? ":Value = nPort " , nPort ? ":Value = nSendOpt " , nSendOpt ? ":Value = lAuth " , lAuth ? ":Value = cSSL " , cSSL ? ":Value = Alltrim(cUser)" , Alltrim(cUser) ? ":Value = AllTrim(cPass)" , AllTrim(cPass) Try oCfg := CREATEOBJECT( "CDO.Configuration" ) WITH OBJECT oCfg:Fields :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value = AllTrim(cMailServer) :Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value = nPort :Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value = nSendOpt :Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = lAuth :Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value = cSSL :Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value = Alltrim(cUser) :Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value = AllTrim(cPass) :Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value = 30 :Update() END WITH CATCH oError MsgInfo( "Não Foi possível Enviar o e-Mail!" +CRLF+ ; "Error: " + Transform(oError:GenCode, nil) + ";" +CRLF+ ; "SubC: " + Transform(oError:SubCode, nil) + ";" +CRLF+ ; "OSCode: " + Transform(oError:OsCode, nil) + ";" +CRLF+ ; "SubSystem: " + Transform(oError:SubSystem, nil) + ";" +CRLF+ ; "Mensaje: " + oError:Description, "CDO.Configuração" ) END TRY oMsg := CreateObject( "CDO.Message" ) With Object oMsg :Configuration = oCfg :From = AllTrim(cFrom) :To = AllTrim(cTo) :Subject = AllTrim(cSubject) :MDNRequested = .F. :TextBody = AllTrim(cBody) For nEle := 1 To Len( aAttach ) :AddAttachment = AllTrim(aAttach[ nEle ]) Next If ! Empty( cBCC ) :BCC = AllTrim(cBCC) EndIf ? "send" :Send() End With MsgInfo("Mensagem Enviada com Sucesso!","Atençao") lRet := .t. Catch oError CursorArrow() MsgStop( "Não foi possível enviar a mensagem para "+AllTrim(cTo) + CRLF + ; "Error: " + cValToChar( oError:GenCode) + CRLF + ; "SubC: " + cValToChar( oError:SubCode ) + CRLF + ; "OSCode: " + cValToChar( oError:OsCode ) + CRLF + ; "SubSystem: " + cValToChar( oError:SubSystem ) + CRLF + ; "Mensagem: " + oError:Description ) lRet := .f. End Try oCfg := Nil oMsg := Nil If lRet MsgInfo("Email Enviado com Sucesso","Email") End CursorArrow() Return ( lRet ) Quote Link to comment Share on other sites More sharing options...
JUDSON ROSA Posted March 5, 2018 Author Report Share Posted March 5, 2018 vou criar um hotmail , so para gerenciar esses tipos de emails para nossos clientes Quote Link to comment Share on other sites More sharing options...
sistem Posted March 6, 2018 Report Share Posted March 6, 2018 Judson se não for pedir muito poderia simular com vbscript da mesma maneira que vc fez com cdosys nos meus testes não trabalha bem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.