Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [delphi5] opzioni varie nell'invio di email

    Ho questo problema....
    Tramite una programma Delphi, cliccando su una mail, devo aprire in automatico il client di posta elettronica ed eseguire queste due opzioni:
    1) passare in automatico il file del cliente come attachment
    2) e visualizzare il body del messaggio in una tabella, realizzata con un file html.

    Il problema è che riesco a realizzare o il punto 1 o il punto 2, questo perchè utilizzo la stessa tecnica, (vedere commenti in basso, la parte commentata con gli asterischi realizzo il punto 1, mentre gli slash punto 2), chi ha la pazienza di darmi una mano?

    grazie 100000000000000

    //ho riportato l'intera funzione.

    function SendMailMAPIB1(MapiHandle: THandle; const Subject, Body, FileName, SenderName, SenderEMail,
    RecepientName, RecepientEMail: string; const Attachments: array of string): Integer;
    var
    AMessage: TMapiMessage;
    lpSender,
    lpRecepient: TMapiRecipDesc;
    FileAttach: TMapiFileDesc;
    SM: TFNMapiSendMail;
    MAPIModule: HModule;
    Files, FilesTmp: PMapiFileDesc;
    FileCountAttach:integer;
    begin
    FillChar(AMessage, SizeOf(AMessage), 0);
    with AMessage do
    begin
    if (Subject <> '') then
    begin
    lpszSubject := PChar(Subject)
    end;
    if (Body <> '') then
    begin
    lpszNoteText := PChar(Body)
    end;
    if (SenderEMail <> '') then
    begin
    lpSender.ulRecipClass := MAPI_ORIG;
    if (SenderName = '') then
    begin
    lpSender.lpszName := PChar(SenderEMail)
    end
    else
    begin
    lpSender.lpszName := PChar(SenderName)
    end;
    lpSender.lpszAddress := PChar('SMTP:' + SenderEMail);
    lpSender.ulReserved := 0;
    lpSender.ulEIDSize := 0;
    lpSender.lpEntryID := nil;
    lpOriginator := @lpSender;
    end;
    if (RecepientEMail <> '') then
    begin
    lpRecepient.ulRecipClass := MAPI_TO;
    if (RecepientName = '') then
    begin
    lpRecepient.lpszName := PChar(RecepientEMail)
    end
    else
    begin
    lpRecepient.lpszName := PChar(RecepientName)
    end;
    lpRecepient.lpszAddress := PChar('SMTP:' + RecepientEMail);
    lpRecepient.ulReserved := 0;
    lpRecepient.ulEIDSize := 0;
    lpRecepient.lpEntryID := nil;
    nRecipCount := 1;
    lpRecips := @lpRecepient;
    end
    else
    begin
    lpRecips := nil
    end;
    if (FileName = '') then
    begin
    nFileCount := 0;
    lpFiles := nil;
    end
    else
    begin
    * FillChar(FileAttach, SizeOf(FileAttach), 0);
    * FileAttach.nPosition := Cardinal($FFFFFFFF);
    * FileAttach.lpszPathName := PChar(FileName);
    * nFileCount := 1;
    * lpFiles := @FileAttach;
    end;

    // nFileCount := High(Attachments) - Low(Attachments) + 1;
    // Files := AllocMem(Sizeof(TMapiFileDesc) * nFileCount);
    // lpFiles := Files;
    // FilesTmp := Files;
    // for FileCountAttach := Low(Attachments) to High(Attachments) do begin
    // FilesTmp.nPosition := $FFFFFFFF;
    // FilesTmp.lpszPathname := Pchar(Attachments[FileCountAttach]);
    // Inc(FilesTmp)
    // end;

    end;
    MAPIModule := LoadLibrary(PChar(MAPIDLL));
    if MAPIModule = 0 then
    begin
    Result := -1
    end
    else
    begin
    try
    @SM := GetProcAddress(MAPIModule, 'MAPISendMail');
    if @SM <> nil then
    begin
    Result := SM(0, Application.Handle, AMessage, MAPI_DIALOG, 0);
    end
    else
    begin
    Result := 1
    end;
    finally
    FreeLibrary(MAPIModule);
    end;
    end;
    end;

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,301
    Riportare il codice è una buona idea, ma in questo caso è un po' troppo!

    Per cercare di risolvere il problema, si dovrebbe essere a conoscenza dell'accesso alle funzioni MAPI.

    Il codice che hai scritto - suppongo - è stato preso da qualche parte.

    Non hai tentato di usare magari vie alternative più semplici, ad esempio sfruttando i componenti Indy?

    In alternativa, prova a guardare questo codice che sembra apparentemente simile.

    Ciao!
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  3. #3

    [delphi5] opzioni varie nell'invio di email

    Ciao Alka

    Ho riportato tutto il codice anche perchè se a qualcuno serve puo sempre riutilizzarlo.....solo per questo...!

    grazie 10000 come al solito
    ciao ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.