我想发送邮件通知,其中一个是以HTML数据流式传输的。有没有办法以表格格式发送邮件通知,只有node.js中的基本数据?
我只收到令牌过期的消息。
这是我的代码:
var sendStreamingTemplate = function (req, res) {
authToken = req.headers.authorization;
userAuthObj = JSON.parse(UserAuthServices.userAuthTokenValidator(authToken));
var todayDate = new Date();
var expireDate = new Date(userAuthObj.expire_date);
tokenOK = TokenValidator.validateToken(userAuthObj.user_id, authToken).then(function (userSessions) {
if (userSessions.length === 1) {
if (expireDate >= todayDate) {
StreamingTemplateId = req.params.id;
StreamingTemplate.findById(StreamingTemplateId).then(function (streamingTemplate) {
if (streamingTemplate === null) {
res.status(404).json({
message: 'Streaming not found...'
})
} else {
res.status(200).json(streamingTemplate);
if (streamingTemplate.id === 1){
var streaming;
switch(streaming){
case notification_log.template_id === 1:
html: '<head><style>table, th, td {border: 1px solid black;border-collapse: collapse;}th, td {padding: 10px;text-align: left;}</style></head>' +
'<body><table style="width:100%"><tr><th>Broadcaster</th><th>Broadcasterchannel</th><th>status</th></tr>' +
'case:sudi <tr><td>Sudi</td><td>sudinews channel</td><td>channel is streaming</td><p>Message:Streaming sucessfully running...</p>'+
'}</table></body>'
break;
case notification_log.template_id === 2:
html: '<head><style>table, th, td {border: 1px solid black;border-collapse: collapse;}th, td {padding: 10px;text-align: left;}</style></head>' +
'<body><table style="width:100%"><tr><th>Broadcaster</th><th>Broadcasterchannel</th><th>status</th></tr>' +
'case:kasturi <tr><td>kasthuri</td><td>kasturinews channel</td><td>channel is streaming</td><p>Message:Streaming sucessfully running...</p>'+
'}</table></body>'
break;
case notification_log.template_id === 3:
html: '<head><style>table, th, td {border: 1px solid black;border-collapse: collapse;}th, td {padding: 10px;text-align: left;}</style></head>' +
'<body><table style="width:100%"><tr><th>Broadcaster</th><th>Broadcasterchannel</th><th>status</th></tr>' +
'case:TamilOli <tr><td>TamilOli</td><td>Entertainment channel</td><td>streaming</td><p>Message:Streaming sucessfully running...</p>'+
'}</table></body>'
break;
default:
break;
}
}
}
}).catch(function (err) {
res.status(500).json({
message: 'something went wrong...'
});
});
} else {
res.status(401).json({
message: 'Not Authorized...'
});
}
} else {
res.status(401).json({
message: 'Token Expired...'
});
}
}).catch(function (err) {
res.status(401).json({
message: 'Token Expired...'
});
});
};