Delphi - Indy - 保存GMail草案 [英] Delphi - Indy - saving GMail draft

查看:163
本文介绍了Delphi - Indy - 保存GMail草案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Delphi下的Indy通过Gmail帐户发送消息,使用TIdSMTP和TIdMessage组件。这工作绝对罚款。

I've been using Indy under Delphi to send message via a gmail account, using the TIdSMTP and TIdMessage components. This works absolutely fine.

但是,我的客户端已请求将消息保存到DRAFTS文件夹,以便允许他在实际发送之前对(编程创建的)消息进行更改。

However, my client has requested to save the message to the DRAFTS folder to allow him to make changes to the (programatically created) message before actually sending it.

GMail API应该支持这一点,但提供的示例不是Delphi / Indy格式...我正在寻找最小的编程更改,所以我想要知道是否可能在Indy组件呢? TIdMessage允许使用mfDraft标志,但这并不能阻止在使用IdSMTP1.Send时立即发送消息。

GMail API is supposed to support this, but the provided examples are not in Delphi/Indy formats... I'm looking for minimal programming changes so I'd like to know if it is possible in the Indy components too? TIdMessage allows for a "mfDraft" flag, but this doesn't prevent the message from immediatly being sent when using IdSMTP1.Send

推荐答案

SMTP没有草稿的概念。您必须使用IMAP。

SMTP has no concept of drafts. You have to use IMAP instead.

使用 TIdIMAP4 登录到GMail帐户,称其为 SelectMailBox()方法来选择草稿文件夹,然后调用其中一个 AppendMsg ...()方法来存储草稿根据需要将电子邮件发送到文件夹。

Use TIdIMAP4 to login to the GMail account, call its SelectMailBox() method to select the draft folder, and then call one of its AppendMsg...() methods to store a draft of the email into the folder as needed.

如果要在发送草稿之前更改草稿,则必须从文件夹中检索当前草稿(其中之一 Retrieve ...() UIDRetrieve ...()方法),并根据需要进行编辑,然后删除从文件夹( DeleteMsgs() UIDDeleteMsg()方法)中的当前草稿,并将新草稿添加到文件夹。

If you want to make changes to a draft before sending it, you will have to retrieve the current draft from the folder (one of the Retrieve...() or UIDRetrieve...() methods) and edit is as needed, then delete the current draft from the folder (the DeleteMsgs() or UIDDeleteMsg() method), and append the new draft into the folder.

要实际发送草稿,您必须从草稿文件夹中检索并删除草稿,然后使用SMTP发送。

To actually send a draft, you will have to retrieve and remove it from the draft folder, and then use SMTP to send it.

这篇关于Delphi - Indy - 保存GMail草案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆