[英]Email selection from Excel using Outlook
在Excel中,我有一個聯系人列表,例如:
A B
1 Bob Marley bob.marley@hotmail.com
2 Michael Jackson michael.jackson@outlook.com
3 Freddie Mercury freddie.mercury@gmail.com
是否有一些VBA代碼可以復制電子郵件地址( B1:B3
)並在Outlook中打開新的電子郵件項,然后將電子郵件地址粘貼到電子郵件的“收件人”部分?
我看過以下網絡參考,但它們似乎不起作用:
http://www.slipstick.com/developer/create-a-new-message-using-vba/
那個第一參考幾乎為您完成了它。 只需將硬編碼的“ to”值調整為單元格值即可。 如果您想全部使用三個地址,則將其循環放置。
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
With objMsg
.To = Range("B2").Value
.Subject = "This is the subject"
.Display
End With
Set objMsg = Nothing
End Sub
編輯
這是在我的電腦上測試的
Sub practisemail()
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = Range("B2").Value
.Subject = "This is the subject"
.Display
End With
Set objOutlook = Nothing
Set objMail = Nothing
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.