0
내가이 유용한 라이브러리를 사용하여 첨부 파일을 전송하는 코드를 테스트 한 연락처로 아이폰 OS 메일 클라이언트에 나타납니다 hotmail 또는 gmail 클라이언트를 통해 jpeg 이미지가 표시됩니다. 그러나 iOS 메일 클라이언트를 통해이 동일한 전자 메일을 볼 때 첨부 파일이 "연락처"로 나타나고이 단추를 클릭하면 파일을 새 연락처로 저장할 수있는 옵션이 나타납니다.이메일 첨부 파일
나는 hotmail에서 jpeg 첨부 파일을 전자 메일로 보내려고했지만, 이렇게하면 iOS 클라이언트에 올바르게 표시됩니다.
누구나 이것이 코드 또는 iOS가 잘못되었는지 알 수 있습니까? 나는이 당신을 위해 일하는 희망
NSString *directory = @"text/directory;...
NSString *directory = @"text/jpeg;...
에
//the guts of the message.
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"[email protected]";
testMsg.toEmail = @"[email protected]";
testMsg.relayHost = @"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = @"[email protected]";
testMsg.pass = @"password";
testMsg.subject = @"The message subject";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
// Only do this for self-signed certs!
// testMsg.validateSSLChain = NO;
testMsg.delegate = self;
//email contents
NSDate* now = [NSDate date];
NSString * bodyMessage = [NSString stringWithFormat:@"The message body"];
// email image if it exists
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/file.jpeg"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableArray* parts = [[NSMutableArray alloc] init];
// add plain part
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
bodyMessage ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
[parts addObject: plainPart];
// add attachments
NSData *attachmentData = [NSData dataWithContentsOfFile:jpgPath];
NSString *directory = @"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"file.jpeg\"";
NSString *attachment = @"attachment;\r\n\tfilename=\"file.jpeg\"";
NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys:
directory,kSKPSMTPPartContentTypeKey,
attachment,kSKPSMTPPartContentDispositionKey,
[attachmentData encodeBase64ForData],kSKPSMTPPartMessageKey,
@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
[parts addObject: image_part];
testMsg.parts = parts;
[testMsg send];
이 도구를 사용 했습니까? 전자 메일에 jpeg 이미지를 추가하려고합니다. 나를 위해 일하지 않는 것 같습니다. –
어쨌든 결국 no no가되는 백그라운드 스레드에서 전자 메일을 보내려고했습니다. 나는 프록시 서버를 사용하여 메시지를 중계했다. – Ellis