我尝试使用Gmail API发送附件和附件。到目前为止我的进展:
Call:
glm(formula = Y ~ ., family = binomial, data = datasim)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.79670 -1.06758 0.00754 1.08200 1.69251
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.11504 1.02968 -0.112 0.91104
X1 0.17173 0.31899 0.538 0.59034
X2 -0.01573 0.28294 -0.056 0.95567
X3 -0.36905 0.29577 -1.248 0.21212
X4 -0.34710 0.29518 -1.176 0.23965
X5 0.01733 0.36088 0.048 0.96170
X6 -0.33492 0.38217 -0.876 0.38083
X7 0.20179 0.31615 0.638 0.52328
X8 -0.42734 0.26011 -1.643 0.10040
X9 -0.02750 0.29571 -0.093 0.92590
X10 0.76991 0.26840 2.868 0.00412 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 138.63 on 99 degrees of freedom
Residual deviance: 125.09 on 89 degrees of freedom
AIC: 147.09
Number of Fisher Scoring iterations: 4
票证日志
class func generateRawString(to: NSMutableArray, subject: String, body: String) -> String {
let dateFormatter:NSDateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss Z"; //RFC2822-Format
let todayString:String = dateFormatter.stringFromDate(NSDate())
let userDefaults = NSUserDefaults.standardUserDefaults()
let mailLoggedUser = userDefaults.objectForKey("email") as! String
let username = userDefaults.objectForKey("userName") as! String
let rawMessage = "" +
"Date: \(todayString)\r\n" +
"From: \(username)<\(mailLoggedUser)>\r\n" +
"To: \(self.generateRecipientsToMail(to))\r\n" +
"Subject: \(subject)\r\n\r\n" +
body
return GTLEncodeWebSafeBase64(rawMessage.dataUsingEncoding(NSUTF8StringEncoding))
}
class func sendEmail(to: NSMutableArray, isRecursive:Bool, subject: String, body: String, threadId: String, attachmentBase64: String, completionBlock:(Bool, AnyObject?)->()) {
let gtlMessage = GTLGmailMessage()
gtlMessage.raw = self.generateRawString(to, subject: subject, body: body)
let encodeDataString = attachmentBase64.dataUsingEncoding(NSUTF8StringEncoding)
let upParam = GTLUploadParameters(data: encodeDataString!, MIMEType: "message/rfc822")
if threadId.length > 0 {
gtlMessage.threadId = threadId
}
let appd = UIApplication.sharedApplication().delegate as! AppDelegate
let query = GTLQueryGmail.queryForUsersMessagesSendWithUploadParameters(upParam)
query.message = gtlMessage
appd.service.executeQuery(query, completionHandler: { (ticket, response, error) -> Void in
print("ticket ==> \(ticket)")
print("response ==>\(response)")
print("error ==> \(error)")
})
}
回复日志
GTLServiceTicket 0x7fbb7e2cee00: {
service:<GTLServiceGmail: 0x7fbb7be1b8d0>
authorizer:GTMOAuth2Authentication 0x7fbb7becf9a0:
{
accessToken="ya29.cALoWT-_-iDvILabLWbpP-eQk4rmbSKgbKhc7E4wOBUc51zzxjE3MZ1mV_cZ1zx3EaAY3A", refreshToken="1/5HWoZDNt5bA415zp_T_VcDfR9vWfvSrEo0u3_5O01MhIgOrJDtdun6zK6XiATCKT",
code="4/qB7vLAajswouGzjmMfAJg0CKaiUZbr_-SBzOYjh0ans",
expirationDate="2016-01-20 20:18:08 +0000"
}
fetcher:GTMHTTPUploadFetcher 0x7fbb7e2aa2c0 (https://www.googleapis.com/upload/rpc?uploadType=resumable&prettyPrint=false&upload_id=AEnB2Up6Z7T3bOCZDYD9g9v6oN9dzOozKLFSLoGUL6qTjoB4izNbrJi__ULCtKce_EvEbpKJ0P_w-iSh0mJRMcxLDyhdF_8DRg)
}