我如何通过e-mail
获取发件人indboxSDK
?我试过这个:
InboxSDK.load(2, 'sdk_marcin123_e44a6df9c6').then(sdk => {
sdk.Conversations.registerThreadViewHandler(threadView => {
var tytul=threadView.getSubject();
var contact=threadView.getContacts();
//var contact=sdk.User.getFromContact();
const el = document.createElement("div");
el.innerHTML = '<a href=fire.php?email='+ contact +'>Szukaj klienta</a>';
threadView.addSidebarContentPanel({
title: 'Szukaj w EU',
iconUrl: chrome.runtime.getURL('monkey.png'),
el
});
});
});
但我明白了:
记录错误:TypeError:threadView.getContacts不是函数 在sdk
如何从电子邮件打印并在HTML链接中显示?
答案 0 :(得分:2)
您可以使用MessageView处理程序获取发件人信息,这很简单:
sdk.Conversations.registerMessageViewHandler(function(messageView){
var sender = messageView.getSender();
// {emailAddress:'some@email.com', name: 'Some Name'}
});
但是,正如您所看到的,这超出了ThreadView的范围,因此我建议在两个作用域外部都有一个变量,在MessageView中获取发送者信息,然后在ThreadView中使用它。
我在我开发的扩展中做了类似的事情,并使用setInterval来不断观察我想要使用的变量,在你的情况下它应该是这样的:
InboxSDK.load(2, 'sdk_marcin123_e44a6df9c6').then(sdk => {
var sender;
// Use MessageView to get the sender information
sdk.Conversations.registerMessageViewHandler(messageView => {
sender = messageView.getSender();
});
sdk.Conversations.registerThreadViewHandler(threadView => {
var tytul=threadView.getSubject();
var contact=threadView.getContacts();
const el = document.createElement("div");
setInterval(() => {
if (sender){
// Do something with the sender information
el.innerHTML = '<a href=fire.php?email='+ contact +'>Szukaj klienta</a>';
threadView.addSidebarContentPanel({
title: 'Szukaj w EU',
iconUrl: chrome.runtime.getURL('monkey.png'),
el
});
}
},1000);
});
});
答案 1 :(得分:0)
我试过这个,此代码在从Gmail发送邮件之前就可以使用了。
InboxSDK.load('1', 'sdk_marcin123_e44a6df9c6').then(function (sdk) {
// the SDK has been loaded, now do something with it!
sdk.Compose.registerComposeViewHandler(function (composeView) {
composeView.on('presending', function (event) {
var cv = event.composeView;
cv.insertTextIntoBodyAtCursor(' From Doyenhub Software Solutions LLP.');
var subject = cv.getSubject();
var mail_body = cv.getTextContent();
var toAddress = cv.getToRecipients();
var ccAddress = cv.getCcRecipients();
var bccAddress = cv.getBccRecipients();
//This variables will give the email data from the compose mail box
});
});
希望这会对你有所帮助。