2012-05-25 2 views
2
Set OutApp = CreateObject("Outlook.Application") 
MsgBox (OutApp Is Nothing) 

On Error GoTo errorHandler 
Set OutMail = OutApp.CreateItem(0) 
     'OutMail.Parent.Display '**** 
     On Error Resume Next 
     With OutMail 
      .To = cell.Value 
      .Subject = "Subject" 
      .Body = "Body" 
      .Se 
     End With 
     On Error GoTo errorHandler 
     Set OutMail = Nothing 

전자 메일을 보내려면 회신 번호 OutMail.Parent.Display의 주석을 제거해야합니다. Outlook을 보임으로써 사용자를 그렇게 괴롭 히게해야합니까? 보안 설정인가요?Excel VBA 코드는 Outlook이 표시되어있는 경우에만 작동합니다.

답변

0

아니요 :) 또한 .Se은 질문에 언급 된 코드의 오타가 맞습니까?

이것은 저에게 효과적입니다.

Option Explicit 

Sub Sample() 
    Dim OutApp As Object, OutMail As Object 

    On Error GoTo Whoa 

    Set OutApp = CreateObject("Outlook.Application") 
    Set OutMail = OutApp.CreateItem(0) 

    With OutMail 
     .To = cell.Value 
     .Subject = "Subject" 
     .Body = "Body" 

     .Send '<~~ .Display to display 
    End With 

LetsContinue: 
    Set OutMail = Nothing 
    Set OutApp = Nothing 
    Exit Sub 
Whoa: 
    MsgBox Err.Description 
    Resume LetsContinue 
End Sub