|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
见如下代码,.To = .To & MyCell.Value & ";" ,这句里面的分号不显示,导致最后邮箱名都连在一起了,无法发送。见下图
如果换成其他符号的 话就可以正常显示。
- Sub Macro86()
- 'Step 1: Declare your variables
- Dim OLApp As Outlook.Application
- Dim OLMail As Object
- Dim MyCell As Range
- Dim MyContacts As Range
-
- 'Step 2: Define the range to loop through
- Set MyContacts = Sheets("Contact List").Range("H2:H21")
-
- 'Step 3: Open Outlook
- Set OLApp = New Outlook.Application
- Set OLMail = OLApp.CreateItem(0)
- OLApp.Session.Logon
-
- 'Step 4: Add each address in the contact list
- With OLMail
- .To = ""
- For Each MyCell In MyContacts
- .To = .To & MyCell.Value & ";"
- Next MyCell
- .BCC = ""
- .Subject = "Chapter 11 Sample Email"
- .Body = "Sample file is attached"
- .Attachments.Add ActiveWorkbook.FullName
- .Display
- End With
-
- 'Step 5: Memory cleanup
- Set OLMail = Nothing
- Set OLApp = Nothing
-
-
- End Sub
复制代码
|
|