簡體   English   中英

使用 vbscript 提取電子郵件地址而不是 CC 的電子郵件名稱?

[英]Extract email address instead of email name of the CC using vbscript?

我正在編寫一個 VBScript 來從電子郵件中提取 CC。 當我提取抄送時,它會顯示此人的電子郵件名稱,而不是電子郵件地址。 我在提取“來自”地址時遇到了同樣的問題。 我檢查了來自此人的電子郵件地址類型 (.SenderEmailType) 是 SMTP 還是 EX,並且能夠獲取電子郵件地址而不是電子郵件名稱。 我不知道如何為 CC 做同樣的事情。 我在網上查過,它被寫入循環通過“Mailitems.Recipent”。 我是 vbscript 的新手,不知道該怎么做。 目前我正在使用 .CC 對象來獲取 cc 詳細信息。

Set Arg = WScript.Arguments
dim item1
dim objsubject 
dim intcount
Dim i 
dim savename 
dim vTextFile
dim filename 
dim extension
Dim t
Dim Itimestamp 
dim savefolder 
Dim vSenderEmailAddress
Dim vCcEmailAddress
Dim vFlagTextFileCreate


vFlagTextFileCreate = True
savefolder = "C:\Users\tgssupport\Documents\Automation Anywhere Files\Automation Anywhere\My Scripts\Retro Pricing\junk"
vTextFile = savefolder & "\File Report.txt"
vFlagExcelAttachmentFound = False
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then    'Could not get instance of Outlook, so create a new one
   Err.Clear
   Set olApp = CreateObject("Outlook.Application")
End If
on error goto 0
Set olns = olApp.GetNameSpace("MAPI")
olns.logon "Outlook",,False,True
'6 is for Inbox
Set objFolder = olns.GetDefaultFolder(6)
For each item1 in objFolder.Items

  if item1.Unread=true then
    objsubject = item1.subject
      vCcEmailAddress = item1.CC
      If item1.SenderEmailType = "SMTP" Then
               vSenderEmailAddress = item1.SenderEmailAddress
      ElseIf item1.SenderEmailType = "EX" Then
               vSenderEmailAddress = item1.Sender.GetExchangeUser.PrimarySmtpAddress
      End If 'If item1.SenderEmailType
      msgbox vCcEmailAddress.
      msgbox vSenderEmailAddress.
  end if 'if item1.Unread=true
Next
olns.logoff
Set olns  = Nothing
Set olApp = Nothing
WScript.Quit
With item1.Recipients
    For i = 1 To .Count
        If .Item(i).Type = OlMailRecipientType.olCC Then
            vCcEmailAddress = .Item(i).Address
            Exit For
        End If
    Next i
End With
Set objFolder = olns.GetDefaultFolder(6)
For each item1 in objFolder.Items      
   For Each RecipientObject In item1.Recipients
      If RecipientObject.Type = 2 Then
      msgbox RecipientObject.Address
      End if
   Next
Next

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM