iOS Development note--ios background send mail

Source: Internet
Author: User

Skpsmtpmessage is an iOS third-party background send mail library https://github.com/jetseven/skpsmtpmessage.git

Original address: http://www.cnblogs.com/U-tansuo/p/ios_send_email.html

-(void) Statrupload: (ID) sender
{
Skpsmtpmessage *testsend = [[Skpsmtpmessage alloc]init];
Testsend.fromemail = @ "Outgoing mailbox";
Testsend.toemail = @ "Mail Inbox";
Testsend.relayhost = @ "smtp.163.com";
Testsend.requiresauth = YES;
Testsend.login = @ "user name;
Testsend.pass = @ "password;
Testsend.subject = [NSString stringwithcstring: "Test" encoding:nsutf8stringencoding];
Testsend.ccemail = @ "CC Mail";
Testsend.wantssecure = YES;
Testsend.delegate = self;

Nsdictionary *plainpart = [nsdictionary dictionarywithobjectsandkeys:@ "Text/plain", Kskpsmtppartcontenttypekey,
@ "This is a tést messåge.", kskpsmtppartmessagekey,@ "8bit", Kskpsmtppartcontenttransferencodingkey,nil];

NSString *vcfpath = [[NSBundle mainbundle] pathforresource:@ "test" oftype:@ "VCF"];
NSData *vcfdata = [NSData Datawithcontentsoffile:vcfpath];
Contacts
Nsdictionary *vcfpart = [Nsdictionary dictionarywithobjectsandkeys:@ "text/directory;\r\n\tx-unix-mode=0644;\r\n\ Tname=\ "test.vcf\" ", Kskpsmtppartcontenttypekey,
@ "attachment;\r\n\tfilename=\" test.vcf\ "", Kskpsmtppartcontentdispositionkey,[vcfdata EncodeBase64ForData], kskpsmtppartmessagekey,@ "base64", Kskpsmtppartcontenttransferencodingkey,nil];
Send picture attachment
NSString *imgpath = [[NSBundle mainbundle] pathforresource:@ "test" oftype:@ "jpg"];
NSData *imgdata = [NSData Datawithcontentsoffile:imgpath];
Nsdictionary *imagepart = [Nsdictionary dictionarywithobjectsandkeys:@ "Image/jpg;\r\n\tx-unix-mode=0644;\r\n\tname =\ "Test.jpg\" ", Kskpsmtppartcontenttypekey,
@ "attachment;\r\n\tfilename=\" test.jpg\ "", Kskpsmtppartcontentdispositionkey,[imgdata EncodeBase64ForData], kskpsmtppartmessagekey,@ "base64", Kskpsmtppartcontenttransferencodingkey,nil];
Send Video Accessories
Attach Video
NSString *videopath = [[NSBundle mainbundle] pathforresource:@ "video" oftype:@ "mov"];
NSData *videodata = [NSData Datawithcontentsoffile:videopath];
Nsdictionary *videopart = [Nsdictionary dictionarywithobjectsandkeys:@ "video/quicktime;\r\n\tx-unix-mode=0644;\r\n \tname=\ "Video.mov\" ", Kskpsmtppartcontenttypekey,
@ "attachment;\r\n\tfilename=\" video.mov\ "", Kskpsmtppartcontentdispositionkey,[videodata EncodeBase64ForData], kskpsmtppartmessagekey,@ "base64", Kskpsmtppartcontenttransferencodingkey,nil];

Testmsg.parts = [Nsarray arraywithobjects:plainpart,vcfpart, Imagepart, Videopart, nil];
Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{
[Testsend send];
});
}

iOS Development note--ios background send mail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.