Repository navigation
Expand file tree
/
Copy pathMail.js
More file actions
69 lines (52 loc) · 1.4 KB
/
Copy pathMail.js
File metadata and controls
69 lines (52 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Mail {
constructor(clientname, id) {
this.clientname = clientname
this.messageId = id
this.headers = {}
this.body = null
this.subject = null
this.date = null
this.attachments = []
this.from = null
this.to = null
this.runInfo = null
}
setHeader(headers) {
this.headers = headers
return this
}
setBody(body) {
this.body = body
return this
}
setSubject(subject) {
this.subject = subject
return this
}
setDate(date) {
this.date = date
return this
}
setAttachments(attachments) {
this.attachments = attachments || []
return this
}
fetch (mailBackend, callback) {
const mailId = this.messageId
var self = this
mailBackend.findMail(mailId, (err, mailDoc) => {
if (err) return callback(err)
if (!mailDoc) return callback("Cannot find mail by id: " + mailId)
self.headers = mailDoc.headers
self.body = mailDoc.body
self.date = mailDoc.date
self.from = mailDoc.from
self.to = mailDoc.to
self.subject = mailDoc.subject
self.runInfo = mailDoc.runInfo
self.attachments = mailDoc.attachments
callback(null, self)
})
}
}
module.exports = Mail