delegate权限可以archive邮件如何打开对方的邮件吗

iOS开发-发送邮件(E-mail)方法整理合集(共3种)_iOS开发_动态网站制作指南
iOS开发-发送邮件(E-mail)方法整理合集(共3种)
来源:人气:9920
前言:在IOS开发中,有时候我们会需要用到邮件发送的功能。比如,接收用户反馈和程序崩溃通知等等。其实这个功能是很常用的,因为我目前就有发送邮件的开发需求,所以顺便整理下IOS发送邮件的方法。
IOS原生自带有两种方法发送邮件的方法,另一种是使用第三方库:
1)openURL(原生)
    &&用户体验较差,程序会进入后台,跳转至邮件发送界面。
2)MFMailComposeViewController(原生)
    &&不会进入后台,使用模态弹出邮件发送视图。
3)SKPSMTPMessage()
    &&你可以不需要告知用户将要进行邮件发送的事情,我在想这个是不是不符合苹果的理论。当然你也可以在发送之前弄个弹出框告知用户,并让用户选择是否发送。
以下代码均在真机(IOS8.0)进行测试,并通过测试。
一、使用openURL发送邮件:
创建可变的地址字符串对象:
NSMutableString *mailUrl = [[NSMutableString alloc] init];
添加收件人:
NSArray *toRecients = @[@"写你们自己的邮箱测试@.com"];
// 注意:如有多个收件人,可以使用componentsJoinedByString方法连接,连接符为@","
[mailUrl appendFormat:@"mailto:%@", toRecipients[0]];
添加抄送人:
NSArray *ccRecipients = @[@""];
[mailUrl appendFormat:@"?cc=%@", ccRecipients[0]];
添加密送人:
NSArray *bccRecipients = @[@"shana_"];
[mailUrl appendFormat:@"&bcc=%@", bccRecipients[0]];
添加邮件主题和邮件内容:
[mailUrl appendString:@"&subject=my email"];
[mailUrl appendString:@"&body=&b&Hello&/b& World!"];
注意:如果你没添加抄送或密送,主题需要设为&?subject=my email,不然邮件会没有主题。
mailto的用法,例:&a href="mailto:?subject=test&cc=&body=use mailto sample"&send mail&/a&
详情可以自行去查看语法,谢谢。
打开地址,这里会跳转至邮件发送界面:
NSString *emailPath = [mailUrl stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[[UI sharedApplication] openURL:[NSURL URLWithString:emailPath]];
二、使用MFMailComposeViewController发送邮件
使用前注意:
1)项目需要导入框架:MessageUI.framework
2)使用的Controlelr里导入头文件:#import &MessageUI/MessageUI.h&
获取用户是否设置了邮件账户:
if ([MFMailComposeViewController canSendMail]) { // 用户已设置邮件账户
[self sendEmailAction]; // 调用发送邮件的代码
sendEmailAction方法代码:
- (void)sendEmailAction
// 邮件服务器
MFMailComposeViewController *mailCompose = [[MFMailComposeViewController alloc] init];
// 设置邮件代理
[mailCompose setMailComposeDelegate:self];
// 设置邮件主题
[mailCompose setSubject:@"我是邮件主题"];
// 设置收件人
[mailCompose setToRecipients:@[@"邮箱号码"]];
// 设置抄送人
[mailCompose setCcRecipients:@[@"邮箱号码"]];
// 设置密抄送
[mailCompose setBccRecipients:@[@"邮箱号码"]];
设置邮件的正文内容
NSString *emailContent = @"我是邮件内容";
// 是否为HTML格式
[mailCompose setMessageBody:emailContent isHTML:NO];
// 如使用HTML格式,则为以下代码
[mailCompose setMessageBody:@"&html&&body&&p&Hello&/p&&p&World!&/p&&/body&&/html&" isHTML:YES];
UIImage *image = [UIImage imageNamed:@"image"];
NSData *imageData = UIImagePNGReesentation(image);
[mailCompose addAttachmentData:imageData mimeType:@"" fileName:@"custom.png"];
NSString *file = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
NSData *pdf = [NSData dataWithContentsOfFile:file];
[mailCompose addAttachmentData:pdf mimeType:@"" fileName:@"7天精通IOS233333"];
// 弹出邮件发送视图
[self presentViewController:mailCompose animated:YES completion:nil];
MFMailComposeViewControllerDelegate的代理方法:
- (void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError *)error
switch (result)
case MFMailComposeResultCancelled: // 用户取消编辑
NSLog(@"Mail send canceled...");
case MFMailComposeResultSaved: // 用户保存邮件
NSLog(@"Mail saved...");
case MFMailComposeResultSent: // 用户点击发送
NSLog(@"Mail sent...");
case MFMailComposeResultFailed: // 用户尝试保存或发送邮件失败
NSLog(@"Mail send errored: %@...", [error localizedDescription]);
// 关闭邮件发送视图
[self dismissViewControllerAnimated:YES completion:nil];
程序运行效果图:
在IOS的邮件发送里,附件会直接显示在正文的下方,但是不要误认为是图片放在了正文当中,两者是有区别的!
三、 使用第三方库SKPSMTPMessage发送邮件&
使用前注意:
1)下载第三方库(下载地址文章开头)
2)导入类#import "SKPSMTPMessage.h"、#import "NSData+Base64Additions.h"
设置基本参数:
SKPSMTPMessage *mail = [[SKPSMTPMessage alloc] init];
[mail setSubject:@"我是主题"];
// 设置邮件主题
[mail setToEmail:@"填你们自己的@qq.com"]; // 目标邮箱
[mail setFromEmail:@"填你们自己的@qq.com"]; // 发送者邮箱
[mail setRelayHost:@"smtp.qq.com"]; // 发送邮件代理服务器
[mail setRequiresAuth:YES];
[mail setLogin:@"填你们自己的@qq.com"]; // 发送者邮箱账号
[mail setPass:@"填你们自己的"]; // 发送者邮箱密码
[mail setWantsSecure:YES];
// 需要加密
[mail setDelegate:self];
设置邮件正文内容:
NSString *content = [NSString stringWithCString:"测试内容" encoding:NSUTF8StringEncoding];
NSDictionary *plainPart = @{kSKPSMTPPartContentTypeKey : @"text/plain", kSKPSMTPPartMessageKey : content, kSKPSMTPPartContentTransferEncodingKey : @"8bit"};
添加附件(以下代码可在SKPSMTPMessage库的DMEO里找到):
NSString *vcfPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"vcf"];
NSData *vcfData = [NSData dataWithContentsOfFile:vcfPath];
NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/\r\n\tx-unix-mode=0644;\r\n\tname=\"test.vcf\"",kSKPSMTPPartContentTypeKey,
@"\r\n\tfilename=\"test.vcf\"",kSKPSMTPPartContentDispositionKey,[vcfData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
执行发送邮件代码:
[mail setParts:@[plainPart, vcfPart]]; // 邮件首部字段、邮件内容格式和传输编码
[mail send];
SKPSMTPMessage代理,可以获知成功/失败进行后续步骤处理:
- (void)messageSent:(SKPSMTPMessage *)message
NSLog(@"%@", message);
- (void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
NSLog(@"message - %@\nerror - %@", message, error);
什么效果图?没有效果图,只因任性。
这里采取的是不通知用户发送邮件,所以没效果图。
小结:本来第三方库那个我是不想写出来的,因为总感觉不安全,不要问我为什么,男人的直觉?其实是代码太难看懂了,可能是我技术太菜了。
本篇文章借鉴了:
http://blog.sina.com.cn/s/blog_7d280d7c0101da7d.html
http://www.cnblogs.com/zhuqil/archive//2112816.html
http://blog.csdn.net/zhibudefeng/article/details/7677421
博文作者:GarveyCalvin
博文出处:
本文版权归作者和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作!
优质网站模板为什么老板发给我的邮件都在Archive里,收件箱里看不到,我用的是yahoo邮箱_百度知道
为什么老板发给我的邮件都在Archive里,收件箱里看不到,我用的是yahoo邮箱
我有更好的答案
方法和步骤:1没用vpn或在国外是注册不了的,因为被中国给限制了,即使帮你申请了最近或平时也是经常使用不了的,而且帮你注册的人家随时可以修改密码,不安全,没保障。如果真的要用。2、51vpn支持国外就可以了
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。邮件archive是什么意思_百度知道
邮件archive是什么意思
我有更好的答案
Archive now就是马上备份你的邮件,Archive就是按计划备份,比如:你定义几星期前的邮件需要备份。
为您推荐:
其他类似问题
您可能关注的内容
邮件的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Manage permissions for recipients
Related Sites
Certifications
Other resources
More support
Not an IT pro?
Manage permissions for recipients
Expand the table of content
Manage permissions for recipients
Exchange 2016
Applies to: Exchange Server 2016 Topic Last Modified:
Summary: Learn how to assign permissions for mailboxes and groups in Exchange 2016 so other users can open the mailbox, send mail from the mailbox, or send mail from the group. In Exchange Server 2016, you can use the Exchange admin center (EAC) or the Exchange Management Shell to assign permissions to a mailbox or group so that other users can access the mailbox (the Full Access permission), or send email messages that appear to come from the mailbox or group (the Send As or Send on Behalf permissions). The users that are assigned these permissions on other mailboxes or groups are called delegates. The permissions that you can assign to delegates for mailboxes and groups in Exchange 2016 are described in the following table*:
Permission
Description
Available on objects in the EAC
Available on addtional objects in the Exchange Management ShellAvailable delegate types in the EACAdditional delegate types available in the Exchange Management Shell
Full Access
Allows the delegate to open the mailbox, and view, add and remove the contents of the mailbox. Doesn't allow the delegate to send messages from the mailbox.If you assign this permission to a mailbox that's hidden from address lists, the delegate won't be able to open the mailbox. By default, arbitration and discovery mailboxes are hidden from address lists.By default, the mailbox auto-mapping feature uses Autodiscover to automatically open the mailbox in the delegate's Outlook profile (in addition to their own mailbox). If you don't want this to happen, you need to take one of the following actions:Use the Add-MailboxPermission cmdlet in the Exchange Management Shell to assign the Full Access permission with the -AutoMapping $false setting. For more information, see the
section in this topic.Assign the Full Access permission to a (mail-enabled) security group. The mailbox won't open in the Outlook profile of each member. User mailboxes Linked mailboxesResource mailboxesShared mailboxesArbitration mailboxesDiscovery mailboxesMailboxes with user accountsMail users with accountsMail-enabled security groups.User accounts that aren't mail-enabled.Universal, global, and domain local security groups that aren't mail-enabled.
Allows the delegate to send messages as if they came directly from the mailbox or group. There's no indication that the message was sent by the delegate.Doesn't allow the delegate to read the contents of the mailbox. User mailboxes Linked mailboxesResource mailboxesShared mailboxesDistribution groupsDynamic distribution groupsMail-enabled security groupsn/aMailboxes with user accountsMail users with accountsMail-enabled security groups.n/a
Send on Behalf Allows the delegate to send messages from the mailbox or group. The From address of these messages clearly shows that the message was sent by the delegate ("&Delegate& on behalf of &MailboxOrGroup&"). However, replies to these messages are sent to the mailbox or group, not to the delegate.Doesn't allow the delegate to read the contents of the mailbox. User mailboxes Linked mailboxesResource mailboxesDistribution groupsDynamic distribution groupsMail-enabled security groupsShared mailboxesMailboxes with user accountsMail users with accountsMail-enabled security groups.Distribution groupsn/a
*Although you can use the Exchange Management Shell to assign some or al of these permissions to other delegate types on other kinds of recipient objects, this topic focuses on the delegate and recipient object types that produce useful results.
Estimated time to complete each procedure: 2 minutes.
To learn how to open the Exchange Management Shell in your on-premises Exchange organization, see .
Procedures in this topic require specific permissions. See each procedure for its permissions information.
For information about keyboard shortcuts that may apply to the procedures in this topic, see .
Having problems? Ask for help in the Exchange forums. Visit the forums at: , , or ..
In the EAC, click Recipients in the feature pane. Depending on the type of mailbox that you want to assign permissions for, click on one of the following tabs:Mailboxes
User or linked mailboxes.Resources
Room or equipment mailboxes.Shared
Shared mailboxes.In the list of mailboxes, select the mailbox that you want to assign permissions for, and then click Edit .On the mailbox properties page that opens, click Mailbox delegation and configure one or more of the following permissions:Send As
Messages sent by a delegate appear to come from the mailbox.Send on Behalf
Messages sent by a delegate have "&Delegate& on behalf of &Mailbox&" in the From address.
Note that this permission isn't available in the EAC for shared mailboxes.Full Access
The delegate can open the mailbox and do anything except send messages.To assign permissions to delegates, click Add
under the appropriate permission. A dialog box appears that lists the users or groups that can have the permission assigned to them. Select the user or group from the list, and then click Add. Repeat this process as many times as necessary. You can also search for users or groups in the search box by typing all or part of the name, and then clicking Search . When you are finished selecting delegates, click OK.To remove a permission from a delegate, select the delegate in the list under the appropriate permission, and then click Remove .When you are finished, click Save. In the EAC, navigate to Recipients & Mailboxes.Select the mailboxes that you want to assign permissions for. Use click + Shift key + click to select a range of mailboxes, or Ctrl key + click to select multiple individual mailboxes. The title of the details pane changes to Bulk Edit as shown in the following diagram.Note that the mailboxes that you select need to be the same type. For example, if you select both user mailboxes and linked mailboxes, you'll get a warning in the details pane that says bulk edit won't work.At the bottom of the details pane, click More options. Under the
Mailbox Delegation option that appears, choose Add or Remove. Depending on your selection, do one of the following steps:Add
In the Bulk Add Delegation dialog box that appears, click Add
under the appropriate permission (Send As, Send on Behalf, or Full Access). When you are finished selecting users or groups to add as delegates, click Save.Remove
In the Bulk Remove Delegation dialog box that appears, click Add
under the appropriate permission (Send As, Send on Behalf, or Full Access). When you are finished selecting users or groups to remove from the existing delegates, click Save. In the EAC, navigate to Recipients & Groups.In the list of groups, select the group that you want to assign permissions for, and then click Edit .On the group properties page that opens, click Group delegation and configure one of the following permissions:Send As
Messages sent by a delegate appear to come from the group.Send on Behalf
Messages sent by a delegate have "&Delegate& on behalf of &Group&" in the From address.To assign permissions to delegates, click Add
under the appropriate permission. A dialog box appears that lists the users or groups that can have the permission assigned to them. Select the user or group from the list, and then click Add. Repeat this process as many times as necessary. You can also search for users or groups in the search box by typing all or part of the name, and then clicking Search . When you are finished selecting delegates, click OK.To remove a permission from a delegate, select the delegate in the list under the appropriate permission, and then click Remove .When you are finished, click Save. You use the Add-MailboxPermission and Remove-MailboxPermission cmdlets to manage the Full Access permission for mailboxes. These cmdlets use the same basic syntax:
Add-MailboxPermission -Identity &MailboxIdentity& -User &DelegateIdentity& -AccessRights FullAccess -InheritanceType All [-AutoMapping $false]
For more information, see .
Remove-MailboxPermission -Identity &MailboxIdentity& -User &DelegateIdentity& -AccessRights FullAccess -InheritanceType All
For more information, see .This example assigns the delegate Raymond Sam the Full Access permission to the mailbox of Terry Adams.
Add-MailboxPermission -Identity "Terry Adams" -User raymonds -AccessRights FullAccess -InheritanceType All
This example assigns Esther Valle the Full Access permission to the organization's default discovery search mailbox, and prevents the mailbox from automatically opening in Esther Valle's Outlook.
Add-MailboxPermission -Identity "DiscoverySearchMailbox{D919BA05-46A6-415f-80AD-7E0}" -User estherv -AccessRights FullAccess -InheritanceType All -AutoMapping $false
This example assigns members of the Helpdesk mail-enabled security group the Full Access permission to the shared mailbox named Helpdesk Tickets.
Add-MailboxPermission -Identity "Helpdesk Tickets" -User Helpdesk -AccessRights FullAccess -InheritanceType All
This example removes Full Access permission for Jim Hance from Ayla Kol's mailbox.
Remove-MailboxPermission -Identity ayla -User "Jim Hance" -AccessRights FullAccess -InheritanceType All
Note: If you've already assigned the Full Access permission to a delegate in the EAC or without using the -AutoMapping $false setting on To verify that you've assigned or removed the Full Access permission for a delegate on a mailbox, use either of the following procedures:In the properties of the mailbox in the EAC, verify the delegate is or isn't listed in Mailbox delegation & Full Access.Run the following command in the Exchange Management Shell to verify the delegate is or isn't listed. Be sure to replace &MailboxIdentity& with the identity of the mailbox.
Get-MailboxPermission &MailboxIdentity& | where {$_.AccessRights -like 'Full*'} | Format-Table -Auto User,Deny,IsInherited,AccessRights
For more information, see . You use the Add-AdPermission and Remove-AdPermission cmdlets to manage Send As permission for mailboxes. These cmdlets use the same basic syntax:
&Add-AdPermission | Remove-AdPermission& -Identity &MailboxOrGroupNameOrDN& -User &DelegateIdentity& [-AccessRights ExtendedRight] -ExtendedRights "Send As"
For more information, see
and .Notes:The Identity parameter requires you to use the Name or DistinguishedName (DN) value of the mailbox or group.Name
This value may or may not be the same as the display name. For example, Felipe Apodaca.DistinguishedName
This value always contains the Name value and uses Active Directory LDAP syntax. For example, CN=Felipe Apodaca,CN=Users,DC=contoso,DC=com.To find these values for a mailbox or group, you can use the Get-Recipient cmdlet, which accepts many different values for the Identity parameter. For example:
Get-Recipient -Identity
| Format-List Name,DistinguishedName
The commands work with or without -AccessRights ExtendedRight, which is why it's shown as optional in the syntax.This example assigns the Send As permission to the Helpdesk mail-enabled security group on the shared mailbox named Helpdesk Support Team.
Add-ADPermission -Identity "Helpdesk Support Team" -User Helpdesk -ExtendedRights "Send As"
This example removes the Send As permission for the user Pilar Pinilla on the mailbox of James Alvord.
Remove-ADPermission -Identity "James Alvord" -User pilarp -ExtendedRights "Send As"
To verify that you've assigned or removed the Send As permission for a delegate on a mailbox or group, use either of the following procedures:In the properties of the mailbox or group in the EAC, verify the delegate is or isn't listed in Mailbox delegation & Send As or Group delegation & Send As.Run the following command in the Exchange Management Shell to verify the delegate is or isn't listed. Be sure to replace &MailboxOrGroupNameOrDN& with the name or distinguished name of the mailbox or group.
Get-ADPermission -Identity &MailboxOrGroupNameOrDN& | where {$_.ExtendedRights -like 'Send*'} | Format-Table -Auto User,Deny,ExtendedRights
For more information, see . You use the Set- cmdlets for the various mailbox and group cmdlets to manage Send on Behalf permission for mailboxes and groups:Set-MailboxSet-DistributionGroup
Distribution groups and mail-enabled security groups.Set-DynamicDistributionGroupThe basic syntax for these cmdlets is:
&Cmdlet& -Identity &MailboxOrGroupIdentity& -GrantSendOnBehalfTo &DelegateIdentity&
&DelegateIdentity& can be one of the following values:To replace any existing delegates with the values you specify, use the syntax &DelegateIdentity1&,&DelegateIdentity2&.... If the delegate identity value contains spaces, you need to use quotation marks: "&DelegateIdentity1&","&DelegateIdentity2&"....To add new delegates without affecting other existing entries, use the syntax @{Add="&DelegateIdentity1&","&DelegateIdentity2&"...}.To remove existing delegates without affecting other delegates, use the syntax @{Remove="&DelegateIdentity1&","&DelegateIdentity2&"...}.To erase all existing delegates, use the value $null.This example assigns the delegate Holly Holt the Send on Behalf permission to the mailbox of Sean Chai.
Set-Mailbox -Identity
-GrantSendOnBehalfTo hollyh
This example adds the group named Temporary Executives to the list of delegates that have Send on Behalf permission to the Contoso Executives shared mailbox.
Set-Mailbox "Contoso Executives" -GrantSendOnBehalfTo @{Add=""}
This example assigns the delegate Sara Davis the Send on Behalf permission to the Printer Support distribution group.
Set-DistributionGroup -Identity
-GrantSendOnBehalfTo sarad
This example removes the Send on Behalf permission that was assigned to the administrator on the All Employees dynamic distribution group.
Set-DynamicDistributionGroup "All Employees" -GrantSendOnBehalfTo @{Remove="Administrator"}
To verify that you've assigned or removed the Send on Behalf permission for a delegate on a mailbox or group, use either of the following procedures:In the properties of the mailbox or group in the EAC, verify the delegate is or isn't listed in Mailbox delegation & Send As or Group delegation & Send As.Run the one of the following commands in the Exchange Management Shell to verify the delegate is or isn't listed. Be sure to replace &MailboxIdentity& or &GroupIdentity& with the identity of the mailbox or group.Mailbox:
Get-Mailbox -Identity &MailboxIdentity& | Format-List GrantSendOnBehalfTo
Get-DistributionGroup -Identity &GroupIdentity& | Format-List GrantSendOnBehalfTo
Dynamic distribution group:
Get-DynamicDistributionGroup -Identity &GroupIdentity& | Format-List GrantSendOnBehalfTo
For more information about how delegates can use the permissions that are assigned to them on mailboxes and groups, see the following topics:
IN THIS ARTICLE
Is this page helpful?
Additional feedback?
1500 characters remaining
Thank you!
We appreciate your feedback.
Did the page load quickly?
Do you like the page design?
Tell us more

我要回帖

更多关于 你的聊天和邮件权限 的文章

 

随机推荐