Adiciona um header personalizado à mensagem.
Sintaxe
AddCustomHeader( < cName >, < cValue > )
Parâmetros
Nome | Tipo | Descrição | Obrigatório | Referência |
---|---|---|---|---|
cName | caractere | Nome do header que será adicionado à mensagem. | X | |
cValue | caractere | Valor do header que será adicionado à mensagem. | X |
Exemplos
Exemplo 1
user function tstAttFile() Local cMsg := "" Local cUser := "", cPass := "" Local xRet Local oServer, oMessage oMessage := TMailMessage():New() oMessage:Clear() oMessage:cDate := cValToChar( Date() ) oMessage:cFrom := "[email protected]" oMessage:cTo := "[email protected]" oMessage:cSubject := "Test" oMessage:cBody := "Email Test" oMessage:AddCustomHeader( "X-Teste", "X-VALUE" ) 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