Yukino Ichikawa
VIP
Một số công ty tích hợp mã nhân viên vào địa chỉ mail.
Chẳng hạn nhập VIN8966 sau đó ấn ctr + K là ra địa chỉ mail trên outlook.
Vậy làm thế nào để lấy thông tin của nhân viên có mã VIN8966 trên VBA Excel?
Chẳng hạn nhập VIN8966 sau đó ấn ctr + K là ra địa chỉ mail trên outlook.
Vậy làm thế nào để lấy thông tin của nhân viên có mã VIN8966 trên VBA Excel?
Mã:
Private Function takelastname(vin As String) As String
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(vin)
Set MyRecipient = MyMail.Recipients.Add(Recipient)
Set MyApp = CreateObject("Outlook.Application")
Set MyMail = MyApp.CreateItem(MailItem)
Set Recipient = MyMail.Recipients.Add(vin)
Set MyRecipient = MyMail.Recipients.Add(Recipient)
On Error GoTo thoat
takelastname = ""
takelastname = MyRecipient.AddressEntry.GetExchangeUser.LastName
thoat:
Set Recipient = Nothing
Set MyRecipient = Nothing
Set MyMail = Nothing
Set MyApp = Nothing
End Function