Tìm thông tin người trong mail outlook

tuhocvba

Administrator
Thành viên BQT
Bài toán 1: Xác nhận một người (VIN06600) có phải là cấp quản lý hay không?
//Chú ý: Phạm vi áp dụng đối với VINF. Vì ở VINF những chức danh từ Chief trở lên đều được thiết định để hiển thị trên Outlook, từ đó có thể lấy về.
Mã:
Sub Test()
    Dim MyApp As Object
    Dim MyMail As Object
    Dim MyRecipient As Object
    Dim Recipient As Object
    Dim temp As String
    
    Set MyApp = CreateObject("Outlook.Application")
    Set MyMail = MyApp.createitem(MailItem)
    Set Recipient = MyMail.Recipients.Add(Range("F2"))    'Nhap du lieu vao F2 tren excel: VIN06600 (ma nhan vien)
    Set MyRecipient = MyMail.Recipients.Add(Recipient)
    
    'Neu tren hai nguoi duoc tim thay, thi co kha nang phat sinh loi
    'Du cho loi phat sinh, chuong trinh van khong dung lai thi hay viet ”On Error Resume Next” o day
    On Error Resume Next
    'Ket qua tim kiem duoc ghi ra day
    Range("B7") = Left(MyRecipient.AddressEntry.GetExchangeUser.Department, 3)
    Range("C7") = MyRecipient.AddressEntry.GetExchangeUser.firstname
    Range("D7") = MyRecipient.AddressEntry.GetExchangeUser.LastName
    Range("E7") = MyRecipient.AddressEntry.GetExchangeUser.PropertyAccessor
    Range("F7") = MyRecipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress
    Range("G7") = MyRecipient.AddressEntry.GetExchangeUser.Alias
    Range("H7") = MyRecipient.AddressEntry.GetExchangeUser.JobTitle
    Range("I7") = MyRecipient.AddressEntry.GetExchangeUser.BusinessTelephoneNumber
End Sub
Chúng ta có thể lấy được nhiều thông tin khác, tham khảo bảng thuộc tính dưới đây.
Bạn cần đăng nhập để thấy đính kèm
 
Top