2017-09-05 1 views
0

난 내 코드 이런 식으로했다 :Outlook VBA 내 코드에 .SentOnBehalfOfName 구현

Public WithEvents myItem As Outlook.MailItem 

Private Sub Application_ItemLoad(ByVal Item As Object) 
If Item.Class = olMail Then 
    Set myItem = Item 
End If 
End Sub 


Private Sub myItem_Open(Cancel As Boolean) 

Dim oAccount As Outlook.Explorer 
Dim oMail As MailItem 

Dim Recip As Outlook.Recipient 

Set oAccount = Application.ActiveExplorer 
MsgBox (oAccount.CurrentFolder.Store) 

If oAccount.CurrentFolder.Store = "[email protected]" Then 
MsgBox ("CC needs to be added") 


Set Recip = myItem.Recipients.Add("[email protected]") 
Recip.Type = olCC 
Recip.Resolve 


Else 
MsgBox ("no need to add CC") 
End If 
End Sub 

내가하고 싶은 내 코드로 = "[email protected]"myItem.SentOnBehalfOfName 같은 것을 추가를 단순히 내 코드에 붙여 작동하지 않습니다. 나는 코딩에 멍청하다. 그래서 나는 아마도 전에 뭔가를 설정해야한다. 아무도 나 한테 이걸 도와 줄 수 없어?

저는 몇 시간 동안 찾고있었습니다. 나는 이미 myItem.SentOnBehalfOfName = "[email protected]"을 시도했지만 실제로 아무것도하지 않는다. 어떤 오류도 표시되지 않으므로 잘못된 점을 알지 못합니다. 아무도 단서가 있습니까?

+0

먼저 검색하십시오. 해당 검색을 기반으로 myItem.SentOnBehalfOfName = "[email protected]"을 코드에 삽입하고 문제가있는 경우 문제에 대해 질문하십시오. – niton

+0

나는 몇 시간 동안 찾고 있었다. 나는 이미 myItem.SentOnBehalfOfName = "[email protected]"을 시도했지만 실제로 아무것도하지 않는다. 어떤 오류도 표시되지 않으므로 잘못된 점을 알지 못합니다. 아무도 단서가 있습니까? – Art

답변

0

이 까다로운 SentOnBehalfOfName 동작은 이전 게시물에 설명되어 있습니다.

Private Sub myItem_Open_SentonBehalf_Test() 

Dim oExpl As Explorer 
Dim myItem As mailitem 

Set oExpl = ActiveExplorer 
Set myItem = CreateItem(olMailItem) 
' Do not display 

If oExpl.CurrentFolder.store = "[email protected]" Then 

    Debug.Print "myItem.SentOnBehalfOfName:" & "x " & myItem.SentOnBehalfOfName & " x" 
    myItem.SentOnBehalfOfName = "[email protected]" 
    Debug.Print "myItem.SentOnBehalfOfName:" & "x " & myItem.SentOnBehalfOfName & " x" 

    ' be careful to put this after updating SentOnBehalfOfName 
    myItem.Display 
    ' Manually display the From field to see the updated entry 

Else 

    Debug.Print "Wrong path." 

End If 

ExitRoutine: 
    Set myItem = Nothing 
    Set oExpl = Nothing 

End Sub