Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.01.21;
Скачать: CL | DM;

Вниз

Ограничение mailto на тело письма   Найти похожие ветки 

 
pvi   (2006-08-21 12:05) [0]

Кто нибудь знает, как с помощью mailto передать текст письма больше 255 символов?


 
Rouse_ ©   (2006-08-21 14:30) [1]

uses ..., MAPI;

// отправка письма с вложением
// =============================================================================
function SendEMail(Handle: THandle; Mail: TStrings): Cardinal;
type
 TAttachAccessArray = array [0..0] of TMapiFileDesc;
 PAttachAccessArray = ^TAttachAccessArray;
var
 MapiMessage: TMapiMessage;
 Receip: TMapiRecipDesc;
 Attachments: PAttachAccessArray;
 AttachCount: Integer;
 i1: integer;
 FileName: string;
 dwRet: Cardinal;
 MAPI_Session: Cardinal;
 WndList: Pointer;
begin
 Result := 0;
 dwRet := MapiLogon(Application.Handle,
   nil,
   nil,
   MAPI_NEW_SESSION + MAPI_LOGON_UI,
   0, @MAPI_Session);

 if (dwRet <> SUCCESS_SUCCESS) then
 begin
   MessageBox(Handle,
     PChar("Error while trying to send email"),
     PChar("Error"),
     MB_ICONERROR or MB_OK);
 end
 else
 begin
   FillChar(MapiMessage, SizeOf(MapiMessage), #0);
   Attachments := nil;
   FillChar(Receip, SizeOf(Receip), #0);

   if Mail.Values["to"] <> "" then
   begin
     Receip.ulReserved := 0;
     Receip.ulRecipClass := MAPI_TO;
     Receip.lpszName := StrNew(PChar(Mail.Values["to"]));
     Receip.lpszAddress := StrNew(PChar("SMTP:" + Mail.Values["to"]));
     Receip.ulEIDSize := 0;
     MapiMessage.nRecipCount := 1;
     MapiMessage.lpRecips := @Receip;
   end;

   AttachCount := 0;

   for i1 := 0 to MaxInt do
   begin
     if Mail.Values["attachment" + IntToStr(i1)] = "" then
       break;
     Inc(AttachCount);
   end;

   if AttachCount > 0 then
   begin
     GetMem(Attachments, SizeOf(TMapiFileDesc) * AttachCount);

     for i1 := 0 to AttachCount - 1 do
     begin
       FileName := Mail.Values["attachment" + IntToStr(i1)];
       Attachments[i1].ulReserved := 0;
       Attachments[i1].flFlags := 0;
       Attachments[i1].nPosition := ULONG($FFFFFFFF);
       Attachments[i1].lpszPathName := StrNew(PChar(FileName));
       Attachments[i1].lpszFileName :=
         StrNew(PChar(ExtractFileName(FileName)));
       Attachments[i1].lpFileType := nil;
     end;
     MapiMessage.nFileCount := AttachCount;
     MapiMessage.lpFiles := @Attachments^;
   end;

   if Mail.Values["subject"] <> "" then
     MapiMessage.lpszSubject := StrNew(PChar(Mail.Values["subject"]));
   if Mail.Values["body"] <> "" then
     MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values["body"]));

   WndList := DisableTaskWindows(0);
   try
   Result := MapiSendMail(MAPI_Session, Handle,
     MapiMessage, MAPI_DIALOG, 0);
   finally
     EnableTaskWindows( WndList );
   end;

   for i1 := 0 to AttachCount - 1 do
   begin
     StrDispose(Attachments[i1].lpszPathName);
     StrDispose(Attachments[i1].lpszFileName);
   end;

   if Assigned(MapiMessage.lpszSubject) then
     StrDispose(MapiMessage.lpszSubject);
   if Assigned(MapiMessage.lpszNoteText) then
     StrDispose(MapiMessage.lpszNoteText);
   if Assigned(Receip.lpszAddress) then
     StrDispose(Receip.lpszAddress);
   if Assigned(Receip.lpszName) then
     StrDispose(Receip.lpszName);
   MapiLogOff(MAPI_Session, Handle, 0, 0);
 end;
end;


пример вызова:

procedure TForm1.Button1Click(Sender: TObject);
var
 Mail: TStringList;
begin
 Mail := TStringList.Create;
 try
   Mail.values["to"] := "почтовый@адрес";
   Mail.values["subject"] := "Тема письма";
   Mail.values["body"] := "Любой текст письма";
   Mail.values["attachment0"] := "Путь к файлу";
   sendEMail(Application.Handle, Mail);
 finally
   Mail.Free;
 end;
end;


 
pvi   (2006-08-22 08:31) [2]

to Rouse_
Спасибо конечно, но мне не нужно было отправлять письмо. Его нужно было просто создать, а отправкой д.б. заниматься пользователь когда ему было нужно. Т.е. функция mailto вполне устраивала если бы не ограничение на тело письма 255 символов. Оказывается это сделать можно, правда работает это только для Outlook и Outlook Express - для The Bat! только 255.


 
Rouse_ ©   (2006-08-22 09:31) [3]

А код проверял? Оно только создается - для отправки пользователю нужно еще пимпу щелкнуть в своем почтовике.



Страницы: 1 вся ветка

Текущий архив: 2007.01.21;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.029 c
4-1157883308
Destroyer
2006-09-10 14:15
2007.01.21
как получить значение переменной среды?


3-1162387159
Layner
2006-11-01 16:19
2007.01.21
cannot sort a row of size 8086..


15-1166026178
shulcsan
2006-12-13 19:09
2007.01.21
О среде разработки


2-1167982840
ro12
2007-01-05 10:40
2007.01.21
Свой пункт в меню.


2-1168007676
FIL-23
2007-01-05 17:34
2007.01.21
изменить цвет кнопок