人们经常向我转发邮件并要求我回复原来在CC的发件人。我认为把这个人放在To字段和CC中的转发器中更为简洁。所以我喜欢交换它们。我想出了这块VBA:
Sub Swap()
Dim objMail As Outlook.MailItem
Set objMail = Application.ActiveInspector.CurrentItem
With objMail
a$ = .To
.To = .CC
.CC = a$
End With
Set objMail = Nothing
End Sub
不幸的是,收件人被复制为文本。所以Outlook将在我们公司的地址簿中再次搜索它们。因为它是一家大公司,有时它会发现错误的人,甚至声称一个人是未知的。
我已经尝试过objmail.Recipients,但我只有一些奇怪的错误。注意:“收件人”和“抄送”字段中可能有多个人。
答案 0 :(得分:0)
您可以从Public Sub Swap()
Dim objOutlook As Outlook.Application ' i use this, because i'm working in MS Access
Dim objMail As Outlook.MailItem
Dim objRecipient As Outlook.recipient
Dim strTo As String
Dim strCC As String
Set objOutlook = GetObject(, "Outlook.Application") ' i use this, because i'm working in MS Access
Set objMail = objOutlook.ActiveInspector.CurrentItem
For Each objRecipient In objMail.Recipients ' here we loop through all recipients
If objRecipient.type = olTo Then ' check if the current recipient is in To section
strCC = strCC & ";" & objRecipient.Address ' add it to the CC string
ElseIf objRecipient.type = olCC Then ' check if the current recipient is in CC section
strTo = strTo & ";" & objRecipient.Address 'add it to the To string
End If
Next objRecipient
If strTo <> "" Then
objMail.To = MID(strTo, 2) ' we cut off the leading semicolon of our string
End If
If strCC <> "" Then
objMail.CC = MID(strCC, 2) ' same here
End If
Set objMail = Nothing
End Sub
中提取电子邮件地址。以下代码在我的机器上正常工作:
add_action( 'wp_head', 'vsmd_meta_description' );
答案 1 :(得分:0)
MailItem类的To属性返回以Outlook分隔的收件人的显示名称的分号分隔字符串列表。此属性仅包含显示名称。相反,应使用Recipients集合来修改收件人。
您只需要获取Recipients集合的实例,请参阅MailItem类的相应属性,该属性返回Outlook项目的收件人对象的集合。然后更改条目的Type属性。
根据收件人的类型,此属性返回或设置一个整数,该整数对应于以下常量之一的数字等效值: