Is it possible to embed images an email being sent from my app? Can we have an tag with source as an image in our app?
是否可以将图像嵌入从我的应用程序发送的电子邮件?我们的应用程序中是否可以将带有源的标记作为图像?
Thanks.
2 个解决方案
#1
Yes. Using 3.0's mail APIs you can.
是。使用3.0的邮件API即可。
I'll not put the code here because it is under the NDA. It is well documented in the SDK though. You need to get the image data into an NSData which is not as obviously documented:
我不会把代码放在这里,因为它在NDA之下。但它在SDK中有详细记录。您需要将图像数据放入NSData中,而不是明显记录的:
NSData* imageData = UIImagePNGRepresentation(myUIImage);
#2
The short answer is that you can't.
简短的回答是,你做不到。
The long answer - I just came across this which includes the TTMessageController class. You'd need to add a delegate to actually do the sending though - i.e. implement SMTP and talk to a known SMTP server. That's not too complicated in itself, but adds some complications regarding error handling, particularly because there's no background processing.
答案很长 - 我刚刚遇到了包括TTMessageController类的内容。您需要添加代理才能实际执行发送 - 即实现SMTP并与已知的SMTP服务器通信。这本身并不复杂,但在错误处理方面增加了一些复杂性,特别是因为没有后台处理。
For example, if your app exits before you've sent the email then you'll need to remember your state and send it next time you start up. The Apple mail application would just send it in the background.
例如,如果您的应用在发送电子邮件之前退出,那么您需要记住您的状态并在下次启动时发送。 Apple邮件应用程序只会在后台发送它。
#1
Yes. Using 3.0's mail APIs you can.
是。使用3.0的邮件API即可。
I'll not put the code here because it is under the NDA. It is well documented in the SDK though. You need to get the image data into an NSData which is not as obviously documented:
我不会把代码放在这里,因为它在NDA之下。但它在SDK中有详细记录。您需要将图像数据放入NSData中,而不是明显记录的:
NSData* imageData = UIImagePNGRepresentation(myUIImage);
#2
The short answer is that you can't.
简短的回答是,你做不到。
The long answer - I just came across this which includes the TTMessageController class. You'd need to add a delegate to actually do the sending though - i.e. implement SMTP and talk to a known SMTP server. That's not too complicated in itself, but adds some complications regarding error handling, particularly because there's no background processing.
答案很长 - 我刚刚遇到了包括TTMessageController类的内容。您需要添加代理才能实际执行发送 - 即实现SMTP并与已知的SMTP服务器通信。这本身并不复杂,但在错误处理方面增加了一些复杂性,特别是因为没有后台处理。
For example, if your app exits before you've sent the email then you'll need to remember your state and send it next time you start up. The Apple mail application would just send it in the background.
例如,如果您的应用在发送电子邮件之前退出,那么您需要记住您的状态并在下次启动时发送。 Apple邮件应用程序只会在后台发送它。