How to get message body and last email in mailcore2?
var session = MCOIMAPSession() // Make Global
session.hostname = "imap.gmail.com"
session.port = 993
session.username = "example@gmail.com"
session.password = "**********"
session.connectionType = MCOConnectionType.TLS
let requestKind: MCOIMAPMessagesRequestKind = [.headers, .flags]
var uidSet = MCOIndexSet(range: MCORangeMake(1, UINT64_MAX))
var fetchOp: MCOIMAPFetchMessagesOperation? = session.fetchMessagesByUIDOperation(withFolder: "INBOX", requestKind: MCOIMAPMessagesRequestKind.headers, uids: uidSet)
fetchOp?.start{( err, msgs, vanished) -> Void in
//print(msgs)
let msgs = msgs as? [MCOIMAPMessage]
for msgs in msgs!{
// THE uid for this email. The uid is unique for one email
let uiid = msgs.uid
useImapFetchContent(uidToFetch: uiid)
}
}
func useImapFetchContent(uidToFetch uid: UInt32)
{
let operation = session.fetchParsedMessageOperation(withFolder: "INBOX", uid: UInt32(uid))
operation?.start{( error, messageParser)-> Void in
if error == nil {
let returnValue = messageParser!.plainTextBodyRenderingAndStripWhitespace(false)
}
let subject = messageParser?.header.subject
print(subject)
let from = messageParser?.header.from
print(from)
let to = messageParser?.header.to
print(to)
let msgPlainBody = messageParser?.plainTextBodyRendering()
print("BODY")
print(msgPlainBody)
}
}
How to store extra header value with MailCore2?
editWith the help of dinhviethoa in the MailCore2 forum on GitHub (https://github.com/MailCore/mailcore2/issues/680), the question could be answered:
- It is not possible to edit the header of an existing email.
- However, it is possible to remove the existing message from the server and append a new message (with extra headers).
Adding MailCore2 via Carthage with Swift Support to Xcode
Need for Carthage to checkout the latest commit. Changing the Cartfile to:
github "MailCore/mailcore2" "master"
Did magic
Related Topics
Ios13 Uialertcontroller with Custom View & Preferredstyle as Actionsheet Grayscale All Colors
Why Does the Compiler Not See the Default Code in a Protocol
How to Make Exponents in the Swiftui
How to Retrieve Audio File from Parse Swift
Swiftui Mysterious Spacing Between Large Text and Textfield in VStack
Cannot Stop Background Music from Within Game Scenes, Swift 3/Spritekit
Let User Save PDF Outside App in iOS Swift
Declaring Conformance to @Objc Protocol in Empty Extension Breaks with Exc_Bad_Instruction
Swift Decodable, Endpoint Returns Completely Different Types
Moving an Object Across the Screen at a Certain Speed.(Sprite Kit)
Tabview, Tabitem: Running Code on Selection or Adding an Ontapgesture
How to Call a Func Within a Closure