1
사람들 목록에 전자 메일을 보내는 데 도움을 찾고 있습니다. 내 코드에는 간단한 루프가 있으며 이메일을 보낼 때마다 값을 매번 가져옵니다. 테스트하는 동안 첫 번째 이메일이 항상 전송됩니다. 그 후, I를 통해 2 시간 항목이 이동 또는 삭제 된 ".TO"전자 메일 여러 수신자 VBA 오류
Run-time error - '-2147221238 (8004010a):
에 오류가 발생합니다.
코드가 다음 전자 메일 값을 정확하게 포착하기 때문에 나에게 당황 스럽습니다.
수신자를 숨은 참조 목록에 추가하는 대신 전자 메일을 하나씩 보내야합니다. VBA로 가능합니까? 미리 감사드립니다!
Sub TestingAgain()
'Setting up the Excel variables.
Dim outApp As Object
Dim outMailItem As Object
Dim iCounter As Integer
Dim sDest As String
Dim sName As String
'Create the Outlook application and the empty email.
Set outApp = CreateObject("Outlook.Application")
Set outMailItem = outApp.CreateItem(0)
With outMailItem
sDest = ""
For i = 2 To WorksheetFunction.CountA(Columns(1))
If i <> "" Then
'Grab first name and email
sDest = Cells(i, 5).Value
sName = Cells(i, 1).Value
'Send each email
.To = sDest
.Subject = "FYI"
.htmlbody = "Some stuff"
.Send
Else
MsgBox ("Error")
End If
Next i
End With
'Clean up the Outlook application.
Set outMailItem = Nothing
Set outApp = Nothing
End Sub
완벽합니다. 고맙습니다. 따라서이 코드 줄에서 : outMailItem = outApp.CreateItem (0) 을 설정하십시오. CreateItem의 "0"은 일을 시작하기위한 출발점 일뿐입니다? – Clint
yw. 아니요 '0'은 itemtype 매개 변수 값입니다. 자세한 내용을 보려면 다음을 참조하십시오. https://msdn.microsoft.com/en-us/library/office/ff869291.aspx – cyboashu