2016-05-25 25 views
0

我们试图知道消息何时被真正发送,并且当消息被标记为SENT时,gmail API似乎通过用户历史间接提供此信息。User.history和实际消息发送

但是,当用户启用了UNDO功能时存在一个问题:虽然邮件尚未真正发送,但邮件被标记为SENT事件。如果撤消,该消息将删除SENT标签并添加DRAFT标签。

到目前为止,我们一直无法找到记录实际发送发生的历史记录中的任何“事件”。

我们需要处理一条已真正发送的消息,并尽可能快地执行,以避免在可能的情况下等待当前可用的最大撤销时间(30秒)。

任何提示我们如何能够实现这一点?我们错过了什么?

回答

0

你可以试试这个

例如PHP代码:

/** 
* Send Message. 
* 
* @param Google_Service_Gmail $service Authorized Gmail API instance. 
* @param string $userId User's email address. The special value 'me' 
* can be used to indicate the authenticated user. 
* @param Google_Service_Gmail_Message $message Message to send. 
* @return Google_Service_Gmail_Message sent Message. 
*/ 
function sendMessage($service, $userId, $message) { 
try { 
$message = $service->users_messages->send($userId, $message); 
print 'Message with ID: ' . $message->getId() . ' sent.'; 
return $message; 
} catch (Exception $e) { 
print 'An error occurred: ' . $e->getMessage(); 
} 
} 

你可以尝试可以得到$message->getId()如果无效,不发送,如果不为空的消息已发送。

if($message->getId() != null){ 
//message has been seent 

your code 
} 
else{ 

//message not been sent 

your code 
} 

或者尝试Advanced search,如果这两个不工作只是粘在目前你正在做什么,因为目前User.history不具备这些功能。

你可以看看在这个环节,他如何使用高级搜索来检查email is sent HTH