delphi – 如何发送带有日历请求的电子邮件(内容类型:文本/日历
发布时间:2020-12-15 09:33:10 所属栏目:大数据 来源:网络整理
导读:我试图将icalendar代码嵌入到电子邮件中,通过indy发送内容类型的文本/日历,但它只是挂在电子邮件的编码上,当我作为附件添加它只是作为附件到达而不提示为其他日历请求.有没有人通过indy得到如何做日历请求的示例代码? 解决方法 以下是RRUZ示例的替代方法:
我试图将icalendar代码嵌入到电子邮件中,通过indy发送内容类型的文本/日历,但它只是挂在电子邮件的编码上,当我作为附件添加它只是作为附件到达而不提示为其他日历请求.有没有人通过indy得到如何做日历请求的示例代码?
解决方法
以下是RRUZ示例的替代方法:
program SendMailWithCalendarRequest; {$APPTYPE CONSOLE} uses IdSMTP,Classes,DateUtils,IdMessage,SysUtils; procedure SendCalendarRequest; var SMTP : TIdSMTP; MailMessage : TIdMessage; begin SMTP:= TIdSMTP.Create(nil); MailMessage := TIdMessage.Create(nil); try SMTP.Host := 'smtp.mailserver.com'; SMTP.Port := 25; SMTP.Username := 'the account'; SMTP.Password := 'the password'; SMTP.AuthType := satDefault; MailMessage.From.Address := 'mail@server.com'; MailMessage.Recipients.EMailAddresses := 'the Recipient'; MailMessage.Subject := 'Send calendar'; MailMessage.Body.Add('BEGIN:VCALENDAR'); MailMessage.Body.Add('VERSION:1.0'); MailMessage.Body.Add('BEGIN:VEVENT'); MailMessage.Body.Add('ORGANIZER:MAILTO:'+SenderMail); MailMessage.Body.Add('DTStart:'+FormatDateTime('YYYY-DD-DD',Now)); MailMessage.Body.Add('DTEnd:'+FormatDateTime('YYYY-DD-DD',Tomorrow)); MailMessage.Body.Add('Location;ENCODING=QUOTED-PRINTABLE: My home'); MailMessage.Body.Add('UID:'+FormatDateTime('YYYY-DD-DD',Now)+FormatDateTime('YYYY-DD-DD',Tomorrow)); MailMessage.Body.Add('SUMMARY:Appointment Reminder'); MailMessage.Body.Add('DESCRIPTION:Test message'); MailMessage.Body.Add('PRIORITY:5'); MailMessage.Body.Add('END:VEVENT'); MailMessage.Body.Add('END:VCALENDAR'); MailMessage.ContentType := 'text/calendar'; SMTP.Connect; try try SMTP.Send(MailMessage) ; Writeln('OK') except on E:Exception do Writeln(0,'ERROR: ' + E.Message) ; end; finally SMTP.Disconnect; end; finally SMTP.Free; MailMessage.Free; end; end; begin try SendCalendarRequest; readln; except on E: Exception do Writeln(E.ClassName,': ',E.Message); end; end. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |