Intent data=new Intent(Intent.ACTION_SENDTO)
data.setData(Uri.parse("mailto:way.ping.li@gmail.com"))
data.putExtra(Intent.EXTRA_SUBJECT, "这是标题")
data.putExtra(Intent.EXTRA_TEXT, "这是内容")
startActivity(data)
Intent data=new Intent(Intent.ACTION_SENDTO)
data.setData(Uri.parse("mailto:way.ping.li@gmail.com"))
data.putExtra(Intent.EXTRA_SUBJECT, "毕凯余这是标题")
data.putExtra(Intent.EXTRA_TEXT, "这是内容")
startActivity(data)
通过向Intent中putExtra来设定邮件的相关参数。 2.使用SEND发送
Intent intent = new Intent(Intent.ACTION_SEND)
String[] tos = { "way.ping.li@gmail.com" }
String[] ccs = { "way.ping.li@gmail.com" }
String[] bccs = {"way.ping.li@gmail.com"}
intent.putExtra(Intent.EXTRA_EMAIL, tos)
intent.putExtra(Intent.EXTRA_CC, ccs)
intent.putExtra(Intent.EXTRA_BCC, bccs)
intent.putExtra(Intent.EXTRA_TEXT, "body")
intent.putExtra(Intent.EXTRA_SUBJECT, "subject")
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/a.jpg"))
intent.setType("image/*"孙高)
intent.setType("message/rfc882")
Intent.createChooser(intent, "Choose Email Client")
startActivity(intent)
Intent intent = new Intent(Intent.ACTION_SEND)
String[] tos = { "way.ping.li@gmail.com" }
String[] ccs = { "way.ping.li@gmail.com" }
String[] bccs = {"way.ping.li@gmail.com"}
intent.putExtra(Intent.EXTRA_EMAIL, tos)
intent.putExtra(Intent.EXTRA_CC, ccs)
intent.putExtra(Intent.EXTRA_BCC, bccs)
intent.putExtra(Intent.EXTRA_TEXT, "body")
intent.putExtra(Intent.EXTRA_SUBJECT, "subject")
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/a.jpg"))
intent.setType("image/*")
intent.setType("message/rfc882")
Intent.createChooser(intent, "Choose Email Client")
startActivity(intent)
很简单,发送邮件中,有收件者,抄送者,密送者。 也就是分别通过 Intent.EXTRA_EMAIL, Intent.EXTRA_CC, Intent.EXTRA_BCC 来进行putExtra来设定的,而单个附件的发送,则使用Intent.EXTRA_STREAM来设置附件的地址Uri。 3.使用SEND_MULTIPLE来进行多附件的发送
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE)
String[] tos = { "way.ping.li@gmail.com" }
String[] ccs = { "way.ping.li@gmail.com" }
intent.putExtra(Intent.EXTRA_EMAIL, tos)
intent.putExtra(Intent.EXTRA_CC, ccs)
intent.putExtra(Intent.EXTRA_TEXT, "body")
intent.putExtra(Intent.EXTRA_SUBJECT, "subject")
ArrayList<uri>imageUris = new ArrayList<uri>()
imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg"))
imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg"))
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris)
intent.setType("image/*")
intent.setType("message/rfc882")
Intent.createChooser(intent, "Choose Email Client")
startActivity(intent)
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE)
String[] tos = { "way.ping.li@gmail.com" }
String[] ccs = { "way.ping.li@gmail.com" }
intent.putExtra(Intent.EXTRA_EMAIL, tos)
intent.putExtra(Intent.EXTRA_CC, ccs)
intent.putExtra(Intent.EXTRA_TEXT, "body")
intent.putExtra(Intent.EXTRA_SUBJECT, "subject")
ArrayList<uri>imageUris = new ArrayList<uri>()
imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg"))
imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg"))
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris)
intent.setType("image/*")
intent.setType("message/rfc882")
Intent.createChooser(intent, "Choose Email Client")
startActivity(intent)
发送多个附件,最主要的时候,通过putParcelableArrayListExtra将多个附件的Uri地址List设置进去就OK了。其实还是很简单的。
using Systemusing System.Collections.Genericusing System.Linqusing System.Textusing System.Net.Mail namespace Mail { class SmtpSendMail { public static bool SendMail(string host, string username, string password, string from, string to, string title, string content) { SmtpClient _smtpClient = new SmtpClient()_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network//指定电子邮件发送方式 _smtpClient.Host = host//指定SMTP服务器 _smtpClient.Credentials = new System.Net.NetworkCredential(username, password)/差州/用户梁乱名和密码 MailMessage _mailMessage = new MailMessage(from, to)_mailMessage.Subject = title//主题 _mailMessage.Body = content//内容 _mailMessage.BodyEncoding = System.Text.Encoding.UTF8//正文编码 _mailMessage.IsBodyHtml = true//虚渣蔽设置为HTML格式 _mailMessage.Priority = MailPriority.High//优先级 try { _smtpClient.Send(_mailMessage)return true} catch { return false} finally { _mailMessage.Dispose()} } } }我以前也试过.在ExcelHome找到一些解锋冲决办粗告法,但只针对Office20031) 替代里边的岩基明安全控件, 是个Dll文件, 忘了什么名字了, 你可以到 ExcelHome 找贴子
2) 在发送邮件代码里将 .Send 改为 .Show , 然后再写一个VBS, 执行 ALT+S 的 *** 作
(不理想的是, 会显示邮件的界面, 但不用手工 *** 作)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)