【问题标题】:VBA - Convert Exchange Online Email Address as SMTP AddressVBA - 将 Exchange Online 电子邮件地址转换为 SMTP 地址
【发布时间】:2023-03-18 04:28:01
【问题描述】:

我从用户那里获得了交换在线地址,但我想转换或以某种方式获取他们的 SMTP 地址。

我不确定如何从 Email1Address 获取 SMTP 地址。

Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)
Set objItems = objContactsFolder.Items

For Each obj In objItems
    'Test for contact and not distribution list
    If obj.Class = olContact Then
        Set objContact = obj

      With objContact

      If .Email1Address <>"" Then
         'I want to add the SMTP-Address after the .LastNameAndFirstName of a User
          strFileAs = .LastNameAndFirstName

         .Email1DisplayName= strFileAs

         .Save
       End If
      End With
    End If

    Err.Clear
Next

【问题讨论】:

标签: vba outlook smtp


【解决方案1】:

我将这个用于电子邮件对象,看看你是否可以实现它:

dim email as string
If myItem.SenderEmailType = "EX" Then
email = myItem.Sender.GetExchangeUser.PrimarySmtpAddress
Else
email = myItem.SenderEmailAdress
End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-16
    • 2013-02-04
    • 2011-03-11
    • 2013-01-24
    • 2011-03-12
    • 2011-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多