是否可以使用 c# 在多米诺骨牌中使用过去的日期发送电子邮件?
It is possible to send emails with past dates using in domino using c#?
当我尝试使用 PostedDate
发送包含过去日期的电子邮件时,发送的电子邮件包含当前日期时间,而不是 PostedDate
字段中指定的日期。可以发送包含过去日期的电子邮件,还有其他方法吗?由于我过去想要大数据来测试备份功能(确实需要)。
static void CreateEmail(NotesDatabase userDatabase)
{
if (!userDatabase.IsOpen)
{
userDatabase.Open();
}
NotesDocument LNDocument = userDatabase.CreateDocument();
string[] recipients =
{"contact1/test@test","contact2/test@test"};
string emailSender = "sender@test.com";
LNDocument.ReplaceItemValue("Form", "Memo");
LNDocument.ReplaceItemValue("From", emailSender);
LNDocument.ReplaceItemValue("SMTPOriginator", emailSender);
LNDocument.ReplaceItemValue("Sender", emailSender);
LNDocument.ReplaceItemValue("INetFrom", emailSender);
LNDocument.ReplaceItemValue("Principal", emailSender);
LNDocument.ReplaceItemValue("SendTo", recipients); //To field
LNDocument.ReplaceItemValue("Subject", "Test Email"); //message subject
LNDocument.ReplaceItemValue("Body", "Test Email Lotus Notes"); //set body text
System.DateTime StartDate = new DateTime(2019, 12, 23, 7, 0, 0);
LNDocument.ReplaceItemValue("PostedDate", StartDate);
LNDocument.SaveMessageOnSend = true; //save message after it's sent
LNDocument.Send(false,recipients ); //send
}
几点说明:
- 为了 C# 中的可读性,更改变量名称,使其以小写字母开头。它使它们与 Class 名称区分开来。 reader 和标记格式。 (至少 LNDocument 和 StartDate)
- 使用调试器,在最后一行设置断点,并检查 LNDocument 变量。日期设置正确吗?
- 在文档中,似乎使用了特定的 NotesDateTime:https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.1/basic/H_NOTESDATETIME_CLASS.html。也许这个日期时间与 System.DateTime?
不兼容
答案很简单:不要发送它们。 "PostedDate"项是路由器自动设置的一项。您无法轻易伪造此日期 ("Hey, but I sent you the mail yesterday, look at the PostedDate..." )。
但是:无需发送邮件,您可以直接在收件人邮箱中直接创建它们,并将所有项目设置为好像确实已发送一样。
路由器唯一做的额外事情就是将邮件放入收件人的收件箱,因此您也需要这样做:
如果您真的想将 "sent" 文档也保存在发件人数据库中,那么可以这样:
而不是
LNDocument.SaveMessageOnSend = true; //save message after it's sent
LNDocument.Send(false,recipients ); //send
写
NotesDatabase recipientDatabase
NotesDocument recipientDocument
LNDocument.Save(true,true,true); //save
// get the database of recipient here, lookup in ($User)- view
// in names.nsf on server and get MailPath, write a function for this...
recipientDatabase = ....
recipientDocument = LNDocument.CopyToDatabase(recipientDatabase)
recipientDocument.PutInFolder( "($Inbox)" )
当我尝试使用 PostedDate
发送包含过去日期的电子邮件时,发送的电子邮件包含当前日期时间,而不是 PostedDate
字段中指定的日期。可以发送包含过去日期的电子邮件,还有其他方法吗?由于我过去想要大数据来测试备份功能(确实需要)。
static void CreateEmail(NotesDatabase userDatabase)
{
if (!userDatabase.IsOpen)
{
userDatabase.Open();
}
NotesDocument LNDocument = userDatabase.CreateDocument();
string[] recipients =
{"contact1/test@test","contact2/test@test"};
string emailSender = "sender@test.com";
LNDocument.ReplaceItemValue("Form", "Memo");
LNDocument.ReplaceItemValue("From", emailSender);
LNDocument.ReplaceItemValue("SMTPOriginator", emailSender);
LNDocument.ReplaceItemValue("Sender", emailSender);
LNDocument.ReplaceItemValue("INetFrom", emailSender);
LNDocument.ReplaceItemValue("Principal", emailSender);
LNDocument.ReplaceItemValue("SendTo", recipients); //To field
LNDocument.ReplaceItemValue("Subject", "Test Email"); //message subject
LNDocument.ReplaceItemValue("Body", "Test Email Lotus Notes"); //set body text
System.DateTime StartDate = new DateTime(2019, 12, 23, 7, 0, 0);
LNDocument.ReplaceItemValue("PostedDate", StartDate);
LNDocument.SaveMessageOnSend = true; //save message after it's sent
LNDocument.Send(false,recipients ); //send
}
几点说明:
- 为了 C# 中的可读性,更改变量名称,使其以小写字母开头。它使它们与 Class 名称区分开来。 reader 和标记格式。 (至少 LNDocument 和 StartDate)
- 使用调试器,在最后一行设置断点,并检查 LNDocument 变量。日期设置正确吗?
- 在文档中,似乎使用了特定的 NotesDateTime:https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.1/basic/H_NOTESDATETIME_CLASS.html。也许这个日期时间与 System.DateTime? 不兼容
答案很简单:不要发送它们。 "PostedDate"项是路由器自动设置的一项。您无法轻易伪造此日期 ("Hey, but I sent you the mail yesterday, look at the PostedDate..." )。
但是:无需发送邮件,您可以直接在收件人邮箱中直接创建它们,并将所有项目设置为好像确实已发送一样。
路由器唯一做的额外事情就是将邮件放入收件人的收件箱,因此您也需要这样做:
如果您真的想将 "sent" 文档也保存在发件人数据库中,那么可以这样:
而不是
LNDocument.SaveMessageOnSend = true; //save message after it's sent
LNDocument.Send(false,recipients ); //send
写
NotesDatabase recipientDatabase
NotesDocument recipientDocument
LNDocument.Save(true,true,true); //save
// get the database of recipient here, lookup in ($User)- view
// in names.nsf on server and get MailPath, write a function for this...
recipientDatabase = ....
recipientDocument = LNDocument.CopyToDatabase(recipientDatabase)
recipientDocument.PutInFolder( "($Inbox)" )