Fórum Converter de RTF para HTML e enviar por email. #297471
28/09/2005
0
tenho que converter um arquivo RTF para HTML. Para realizar esse procedimento estou fazendo confome mostrado abaix:
1 2 3 4 | Wordapp := CreateOleObject(´Word.Application´); Wordapp.Visible := false; Doc := Wordapp.documents.open(´C:\Teste.RTF´); Doc.saveas(´C:\Agenda\Teste.html´, wdFormatHTML, AddToRecentFiles := False); |
Como posso mandar o arquivo por email?
Tentei assim:
1 2 | WordApp.Options.SendMailAttach := False; WordApp.Documents.Item(1).SendMail; |
Mas abre a janela do outlook express. Gostaria de mandar automaticamente, sem interferência do usuário, e pelo programa de email padrão.
Como fazer isso?
Aqui vai um link interessante sobre [b:986b6a6d16]Automating Excel and Word[/b:986b6a6d16]
[url]
http://homepages.borland.com/ccalvert/TechPapers/Delphi/DelphiWord.htm[/url]
[/b]

Carlosib
Curtir tópico
+ 0Posts
28/09/2005
Massuda
Se quiser fazer você mesmo o envio, você pode tentar usar o Indy. Dê uma olhada [url=http://forum.clubedelphi.net/viewtopic.php?t=65357]neste tópico[/url] para ver um exemplo (bem) básico de como enviar email usando Indy. Sobre como enviar email com texto HTML, dê uma olhada no artigo [url=http://www.dragonsoftru.com/?html=indy-email.html]EMAIL MESSAGES FROM DELPHI. USING INDY TO SEND E-MAILS[/url] (de Serge Dosyukov da Dragon Software, em inglês); o artigo explica como gerar diversos tipos de mensagens no Indy (texto simples, texto simples com anexos, HTML e HTML com anexos); a parte 3 explica como gerar uma mensagem formatada em HTML com imagens anexas.
Gostei + 0
28/09/2005
Carlosib
Desculpe, Mussuda, mas estou enrolado e não estou saindo do lugar.... estou tentando com Indy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | with IdMsgSend do begin ContentType := ´text/html; charset=iso-8859-1´; newAttach:= TIdAttachmentFile.Create(MessageParts, ´C:\Mala.RTF´); Headers.Values[´X-Library´] := ´´; ContentType := ´text/html; charset=iso-8859-1´; From.Name := ´Nome´; From.Address := ´email_de_Origem´; ReplyTo.EMailAddresses := ´email_de_destino´; Recipients.EMailAddresses := ´email_de_destino´; { To: header } Subject := ´Arquivo RTF´; Priority := mpHigh; //Prioridade end; |
Desejo que o RTF fique aberto no corpo do email.....
Uso Indy 10.0.75 e Delphi 7.
Gostei + 0
28/09/2005
Massuda
Gostei + 0
28/09/2005
Carlosib
Mas o que desejo é algo similar ao:
Quando estou escrevendo o texto no word...vou no menu Arquivo --> Enviar Para -->> Destinatário da Mensagem. Enviando desta forma o arquivo é visualizado no corpo da mensagem.... não aparece como sendo um anexo.
Me desculpe se falei bobagem :oops: ..... mas é isso que eu desejo.... :cry:
Gostei + 0
28/09/2005
Massuda
Gostei + 0
28/09/2005
Carlosib
Estou tentando assim:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | with IdMsgSend do begin ContentType := ´text/html; charset=iso-8859-1´; lTextPart := TIdText.Create(MessageParts); lTextPart.Body.Text := ´This is a plain text message´; lTextPart.ContentType := ´text/plain; charset=iso-8859-1´; lTextPart := TIdText.Create(MessageParts); lTextPart.Body.Text := ´< html >< body >< b >This is a HTML message</ b ></ body ></ html >´; lTextPart.ContentType := ´text/html; charset=iso-8859-1´; newAttach:= TIdAttachmentFile.Create(MessageParts, ´C:\Mala.RTF´); Headers.Values[´X-Library´] := ´´; ContentType := ´text/html; charset=iso-8859-1´; From.Name := ´Mala´; From.Address := ´carlos@uol.com.br´; ReplyTo.EMailAddresses := ´destino@uol.com.br´; Recipients.EMailAddresses := ´destino@uol.com.br´; { To: header } Subject := ´Mala em RTF´; Priority := mpHigh; //Prioridade end; ...... |
Se eu mandar pelo outlook express vai normal.... via webmal...vai normal.... só com meu código que não funciona.
:oops: :cry:
Gostei + 0
28/09/2005
Massuda
De qualquer forma, acho que isso faz o que você quer...
1 2 3 4 5 6 7 8 9 10 11 12 13 | with IdMsgSend do begin TIdAttachmentFile.Create(MessageParts, ´C:\Mala.RTF´); Headers.Values[´X-Library´] := ´´; From.Name := ´Mala´; From.Address := ´carlos@uol.com.br´; ReplyTo.EMailAddresses := ´destino@uol.com.br´; Recipients.EMailAddresses := ´destino@uol.com.br´; { To: header } Subject := ´Mala em RTF´; Priority := mpHigh; //Prioridade end; |
Gostei + 0
28/09/2005
Carlosib
O arquivo RTF abre como sendo o corpo da mensagem.
Mussuda, se quiseres mando um email para vc para veres o que desejo...Derepente posso esta falando besteira.....
Usando o código como vc relatou o RTF não abre...nem no outlook nem no webmail do click21.
Gostei + 0
28/09/2005
Carlosib
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | From carlosib@brturbo.com.br Wed Sep 28 20:27:08 2005 Return-Path: < carlosib @brturbo.com.br> Delivered-To: carlosib@click21.com.br Received: by mail3.click21.com.br (Postfix, from userid 501) id 4F9AFF736D; Wed, 28 Sep 2005 20:27:08 -0300 (EST) Received: from smtp1.brturbo.com.br (smtp1.brturbo.com.br [200.199.201.163]) by mail3.click21.com.br (Postfix) with ESMTP id D7FD4F7187 for < carlosib @click21.com.br>; Wed, 28 Sep 2005 20:27:07 -0300 (EST) Received: from arthur (unknown [200.193.111.31]) by smtp1.brturbo.com.br (Postfix) with SMTP id 995EC3428; Wed, 28 Sep 2005 20:26:55 -0300 (BRT) Message-ID: < 000501c5c482 $62836ce0$f2c5fea9@arthur> From: "Carlos BR Trubo" < carlosib @brturbo.com.br> To: "Carlos BR Trubo" < carlosib @brturbo.com.br>, < carlosib @click21.com.br> Subject: Pelo word Date: Wed, 28 Sep 2005 20:14:31 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0000_01C5C469.3C967270" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-CRM114-Version: 20040716-BM-OSB [tre] MF-BD1ECE33 X-CRM114-Status: Good ( pR: 8.9777/-5.0 ) This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C5C469.3C967270 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit |
Esse código estou pegando no webmail do click21....
Como fazer?
Gostei + 0
28/09/2005
Massuda
Gostei + 0
29/09/2005
Carlosib
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | with IdMsgSend do begin lTextPart := TIdText.Create(MessageParts); lTextPart.Body.Clear; lTextPart.ContentType := ´text/plain´; lTextPart := TIdText.Create(MessageParts); lTextPart.Body.Clear; lTextPart.Body.LoadFromFile(´C:\Agenda\MalaDireta\Mala.HTML´); lTextPart.ContentType := ´text/html´; Headers.Values[´X-Library´] := ´´; if DirectoryExists(´C:\Agenda\MalaDireta\Mala_Arquivos\´) then begin try for i:=0 to Arquivos.Count - 1 do begin if AnsiUpperCase(ExtractFileExt(Arquivos.Items.strings[i])) <> ´.PNG´ then continue; lImagePart := TIdAttachmentFile.Create(MessageParts, Arquivos.Items.strings[i]); lImagePart.ContentType := ´image/jpg´; lImagePart.Headers.Clear; lImagePart.Headers.Add(´Content-ID: <./Mala_arquivos/´+Arquivos.Items.strings[i]+´>´); end; except on E : Exception do begin showMessage(E.Message); end; end; end; From.Name := ´Mala´; From.Address := ´origem@uol.com.br´; ReplyTo.EMailAddresses := Para; Recipients.EMailAddresses := Para; { To: header } Subject := ´:: Teste HTML ::´; Priority := mpHigh; //Prioridade end; |
A imagem não aparece no local correto....
Gostei + 0
29/09/2005
Massuda
Gostei + 0
29/09/2005
Carlosib
1 | lTextPart.Body.LoadFromFile(´C:\Agenda\MalaDireta\Mala.HTML´); |
No webmail do click21 o arquivo HTML aparece aberto e a imagem fica como anexo.[/code]
Gostei + 0
29/09/2005
Massuda
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | var lMessage: TIdMessage; lTextPart: TIdText; lImagePart: TIdAttachment; begin // ... some code here to initialize your SMTP server. // It could be done somewhere as well lMessage := TIdMessage.Create(Self); lMessage.From.Address := ´myemail@mydomain.com´; lMessage.Subject := ´My test email´; lMessage.Recipients.Add.Address := ´someoneemail@somedomain.com´; lMessage.Body.Clear; lTextPart := TIdText.Create(lMessage.MessageParts); lTextPart.Body.Text := ´This is a plain text message´; lTextPart.ContentType := ´text/plain´; lTextPart := TIdText.Create(lMessage.MessageParts); lTextPart.Body.Text := ´< html >< body >´ + ´< b >This is a HTML message with picture</ b >´ + // isto insere a imagem anexa no texto ´< img src = "htmlbodyIMG0000.JPG" >´ + ´</ body ></ html >´; lTextPart.ContentType := ´text/html´; // isto insere a imagem anexa no texto lImagePart := TIdAttachment.Create(lMessage.MessageParts, ´htmlbodyIMG0000.JPG´); lImagePart.ContentType := ´image/jpg´; lImagePart.Headers.Add(´Content-ID: < htmlbodyIMG0000.JPG >´); // ... A code to send a message end; |
Gostei + 0
29/09/2005
Carlosib
[url]http://www.digilab.com.br/Carlos/01.jpg[/url]
O próximo link mostra o arquivo aberto após ser enviado por email no outlook:
[url]http://www.digilab.com.br/Carlos/02.jpg[/url]
O terceiro link mostra o email aberto no webmail do click21
[url]http://www.digilab.com.br/Carlos/03.jpg[/url]
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)