TMailMessage:MsgBodyType
Permite definir o tipo do corpo do e-mail.
Sintaxe
MsgBodyType( < cValue > )
Parâmetros
Nome | Tipo | Descrição | Obrigatório | Referência |
---|---|---|---|---|
cValue | caractere | Indica o valor do tipo do corpo do e-mail que será definido. Valor padrão: text/html. | X |
Exemplos
Exemplo 1
user function tstAttFile() Local cMsg := "", cFile := "" Local cUser := "", cPass := "" Local xRet Local oServer, oMessage cFile := "\temp\attach.txt" xRet := MemoWrite( cFile, "attachment 1 e-mail" ) if !xRet cMsg := "Could not create attachment " + cFile conout( cMsg ) return endif oMessage := TMailMessage():New() oMessage:Clear() oMessage:cDate := cValToChar( Date() ) oMessage:cFrom := "my.email@totvs.com.br" oMessage:cTo := "other.email@totvs.com.br" oMessage:cSubject := "Test" oMessage:cBody := "Email Test" oMessage:MsgBodyType( "text/plain" ) xRet := oMessage:AttachFile( cFile ) if xRet < 0 cMsg := "Could not attach file " + cFile conout( cMsg ) return endif oServer := TMailManager():New() oServer:SetUseTLS( .T. ) cUser := "username" cPass := "password" xRet := oServer:Init( "", "mail.totvs.com.br", cUser, cPass, 0, 587 ) if xRet != 0 cMsg := "Could not initialize SMTP server: " + oServer:GetErrorString( xRet ) conout( cMsg ) return endif xRet := oServer:SetSMTPTimeout( 60 ) if xRet != 0 cMsg := "Could not set " + cProtocol + " timeout to " + cValToChar( nTimeout ) conout( cMsg ) endif xRet := oServer:SMTPConnect() if xRet <> 0 cMsg := "Could not connect on SMTP server: " + oServer:GetErrorString( xRet ) conout( cMsg ) return endif xRet := oServer:SmtpAuth( cUser, cPass ) if xRet <> 0 cMsg := "Could not authenticate on SMTP server: " + oServer:GetErrorString( xRet ) conout( cMsg ) oServer:SMTPDisconnect() return endif xRet := oMessage:Send( oServer ) if xRet <> 0 cMsg := "Could not send message: " + oServer:GetErrorString( xRet ) conout( cMsg ) endif xRet := oServer:SMTPDisconnect() if xRet <> 0 cMsg := "Could not disconnect from SMTP server: " + oServer:GetErrorString( xRet ) conout( cMsg ) endif return
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas