简体   繁体   中英

Can't send attachments from draft (Mail.app)

I am trying to send a draft created with Mail.app.

As drafts have no send method, I'm having to get all the content from the draft, and create a new e-mail with it. That should be ok, but... Attachments aren't getting through.

I am using this:

outgoing.content = message.content;

Where outgoing is the message I am creating and message is the draft I am reading from.

I tried looping through the attachments of the message and adding them manually but I always get this:

*** -[SBElementArray addObject:]: can't add an object that already exists.

This is how I am looping through them:

for (int i=0; i<[message.content.attachments count]; i++) {
            MailAttachment *anAttachment = [message.content.attachments objectAtIndex:i];
            if (![outgoing.content.attachments containsObject:anAttachment]) {
                NSLog(@"File Path: %@", anAttachment.fileName);
                MailAttachment *newAttachment = anAttachment;
                [outgoing.content.attachments addObject:newAttachment];
            }
}

It should be worth noting that the File Path NSLog always comes out as (null), no matter what.

Would appreciate any help here.

根据我的研究,在阅读消息和获取其内容时,Mail.app的AppleScript / ScriptingBridge API几乎被破坏了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM