Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > mail to with shellexecute how !!!


Автор: huismori 28.1.2011, 22:18
I am trying to send the richedit text to outlook with text attribitues but it gives error saying ;

incompitable types string and pwidechar !!!

Код

procedure TForm1.Button1Click(Sender: TObject);
var s: TStringStream ;
begin
  s:= TStringStream.Create();
  RichEdit1.PlainText:= False;
  RichEdit1.Lines.SaveToStream(s);
  ShellExecute(Self.Handle, nil, 'mailto:[email protected]' + '?Subject=Test&Body='+s.DataString, nil, nil, SW_NORMAL);
end;

Автор: Keeper89 28.1.2011, 22:29
Конечно, а где оно, PChar?
Код

PChar('mailto:[email protected]' + '?Subject=Test&Body='+s.DataString)

Автор: huismori 29.1.2011, 12:00
ok here the code i use but it doesnt send it with text attribitues !!! why is that ???

Код

function SendShellEmail( ARecipientEmail, ASubject, ABody : string ) : boolean; // Send an email to this recipient with a subject and a body
var
iResult : integer;
S       : string;
begin
  If Trim(ARecipientEmail) = '' then
    ARecipientEmail := 'mail';
    S := 'mailto:' + ARecipientEmail;
    S := S + '?subject=' + ASubject;
       If Trim(ABody) <> '' then
         S := S + '&body=' + ABody;
         iResult := ShellExecute( Application.Handle,'open', PChar(S), nil, nil, SW_SHOWNORMAL);
         Result := iResult > 0;
end;

procedure TForm1.Button1Click(Sender: TObject);
var s: TStringStream ;
begin
  s:= TStringStream.Create();
  RichEdit1.PlainText:= False;
  RichEdit1.Lines.SaveToStream(s);
  SendShellEmail('[email protected]','Hello',s.DataString);
end;



outlook body is like that !!!
Цитата

{\rtf1\ansi\ansicpg1254\deff0\deflang1055{\fonttbl{\f0\fnil\fcharset162 Square721 BT;}}{\colortbl ;\red49\green106\blue197;}\viewkind4\uc1\pard\cf1\f0\fs44 RichEdit1\par\par}

Автор: Keeper89 29.1.2011, 14:02
Ну а разве Outlook RTF понимает?

Автор: Akella 29.1.2011, 14:42
Думаю, что поймёт. Только нужно  как-то аутлуку сказать, что это не текст, а форматированный текст.

Автор: huismori 29.1.2011, 14:45
how can i make outlook to understand that it is a rtf text ?

Автор: Akella 29.1.2011, 16:44
You should send mail in HTML format

Добавлено через 14 минут и 12 секунд
Код

ABody := '<html> HTML TEXT WITH TAGS </html>';
S := S + '&body=' + ABody;
ShellExecute( Application.Handle,'open', PChar(S), nil, nil, SW_SHOWNORMAL);

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)