gpt4 book ai didi

delphi - 如何发送带有日历请求的电子邮件(内容类型 : text/calendar)

转载 作者:行者123 更新时间:2023-12-03 15:08:42 26 4
gpt4 key购买 nike

我尝试将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.

关于delphi - 如何发送带有日历请求的电子邮件(内容类型 : text/calendar),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2661469/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com