Following is todays question (sent by me) and a solution from the beginning of the month. But there is a problem. I want to use bits of both.
Mailto: I use em_mail := 'mailto:bob jones, andrew smith?subject=mail test'&body=body would go here'; ShellExecute(Handle, 'open', PChar(em_mail), nil, nil, SW_SHOWNORMAL); which is great because it let's me use our internal mail system full names and it converts them to email addresses that I don't even want to know about. But can I get the mail to actually be sent from delphi? [Indy: I've tried the stuff below and it works as long as I know the actual email addresses which I don't. Also, when the mail arrives at the recipient's client, it is marked as medium level spam because it is expecting external emails to arrive with some sort of message id in the header.] Wayne <my recent message> >I use mailto to generate email around our intranet. The email comes up in my >default email client >and I can add text and send the email. > >Now I want to generate mails and send them all from delphi. I still want to >use my default email >client. I guess I want something like MailtoAndSend. Is this possible? > >I also want to send text formatted in a table using this. Can anyone give me >any tips for this? > >TIA >Wayne <earlier reply to earlier message From: "Rainer von Saleski" > >> There is a very nice Email-sender built into Delphi 7 (it may also be >> available in earlier versions) as part of Indy. >> >> You can find a write-up (with some omissions) at >> http://forums.about.com/n/pfx/forum.aspx?msg=8220.1&nav=messages&webtag=ab-delphi >> >> Here is my wrapper for creating and sending Emails. Just call the >> procedures in the order they appear here (as often as necessary). Be sure >> to change the text strings in EmailInit to reflect your own email account. >> >> Rainer >> >> >> [Begin Code] >> >> unit EmailUnit; >> >> interface >> >> uses >> inifiles, Windows, Messages, SysUtils, Variants, Classes, Graphics, >> Controls, Forms, >> Dialogs, IdComponent, IdTCPConnection, IdTCPClient, IdMessageClient, >> IdSMTP, ComCtrls, StdCtrls, Buttons, ExtCtrls, >> IdBaseComponent, IdMessage, IdEmailAddress; >> >> type >> TEmail = class (TForm) >> MailMessage: TIdMessage; >> SMTP: TIdSMTP; >> end; >> >> var >> Email: TEmail; >> procedure EmailInit (FromName, FromAddr, Subject: string; Body: >> TStrings); >> procedure EmailTo (ToName, ToAddr: string); {May be called more than >> once} >> procedure EmailAttach (FileName: string); {May be called more than >> once} >> procedure EmailSend; >> >> implementation >> >> {$R *.dfm} >> >> procedure EmailInit (FromName, FromAddr, Subject: string; Body: TStrings); >> begin with Email do begin >> >> // SMTP Host >> SMTP.Host :='Email SMTP Server'; >> SMTP.Port := 25; >> >> // User Name and Password >> SMTP.AuthenticationType := atLogin; // or atNone if your host doesn't >> casre who you are >> SMTP.Username := 'Email User Name'; >> SMTP.Password := 'Email Password'; >> >> // Message Parts >> MailMessage.Clear; >> MailMessage.From.Name := FromName; >> MailMessage.From.Address := FromAddr; >> MailMessage.Recipients.Clear; >> MailMessage.Subject := Subject; >> MailMessage.Body.Text := Body.Text; >> end end; >> >> procedure EmailTo (ToName, ToAddr: string); >> var >> EI: TIdEMailAddressItem; >> begin with Email do begin >> EI := MailMessage.Recipients.Add; >> EI.Name := ToName; >> EI.Address := ToAddr; >> end end; >> >> procedure EmailAttach (FileName: string); >> begin with Email do begin >> if FileExists(FileName) >> then TIdAttachment.Create(MailMessage.MessageParts, FileName) >> else ShowMessage (format ('Attachment "%s" not found', [FileName])); >> end end; >> >> procedure EmailSend; >> begin with Email do begin >> try >> try >> SMTP.Connect(1000); >> SMTP.Send(MailMessage); >> except on E:Exception do >> ShowMessage ('Email Error: ' + E.Message); >> end; >> finally >> if SMTP.Connected then SMTP.Disconnect; >> end; >> end end; >> >> end. >> >> [End of Code] >> > _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

