从员工处获取电子邮件地址's的id存储在Excel中



我需要根据员工id获取电子邮件地址。

我从Excel中复制员工ID并将其粘贴到";致";Outlook邮件的字段。

我无法使用宏代码单击ctrl + K

我使用以下代码将员工ID粘贴到Outlook应用程序中。

Sub Combinedata()

Dim i As Integer
Dim count As Integer
Dim s As String
Dim outRec As Object

count = Cells(Rows.count, "A").End(xlUp).Row
For i = 1 To count
s = s & Cells(i, 1) & ";"
Next
'Range("D2") = s

Set OutApp = CreateObject("Outlook.Application")

On Error GoTo 0    
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail                   
.To = s                  
.Display                                    
End With
On Error GoTo 0
Set OutMail = Nothing
End Sub

.Recipients.ResolveAll复制ctrl+K.

Option Explicit ' Consider this mandatory
' Tools | Options | Editor tab
' Require Variable Declaration
'
' If desperate declare as variant
Sub Combinedata()
Dim i As Long
Dim count As Long
Dim s As String
Dim OutApp As Object
Dim outMail As Object
count = Cells(Rows.count, "A").End(xlUp).Row
For i = 1 To count
s = s & Cells(i, 1) & ";"
Next
Set OutApp = CreateObject("Outlook.Application")
Set outMail = OutApp.CreateItem(0)
With outMail
.To = s
.Recipients.ResolveAll
.Display
End With
End Sub

相关内容

最新更新