簡體   English   中英

如何在Outlook中的字段中更改電子郵件ID

[英]How to change email id in from field in outlook

我需要幫助,以找到一種方法來更改將使用VBA發送電子郵件的電子郵件。 以下是我當前的代碼,電子郵件將與我的電子郵件一起發送,我需要將其更改為組電子郵件ID。

Dim olApp As Object
Dim olMail As Object
Dim olRecip As Object
Dim olAtmt As Object
Dim iRow As Long
Dim Recip As String
Dim Subject As String
Dim Atmt As String
Dim sMsgBody As String
Dim strfrom As String



iRow = 2

Set olApp = CreateObject("Outlook.Application")

Dim Sht As Worksheet
Set Sht = ThisWorkbook.Worksheets("Sheet1")

Do Until IsEmpty(Sht.Cells(iRow, 1))

Recip = Sht.Cells(iRow, 1).Value
Subject = Sht.Cells(iRow, 2).Value
Atmt = Sht.Cells(iRow, 3).Value ' Attachment Path


Set olMail = olApp.CreateItem(0)

With olMail
Set olRecip = .Recipients.Add(Recip)
    .Subject = Subject
    .body = sMsgBody
    .Display
    .
Set olAtmt = .Attachments.Add(Atmt)

olRecip.Resolve
End With

iRow = iRow + 1

Loop

Set olApp = Nothing

如果要更改發件人帳戶,請使用“ 發件人”屬性

如果要使用您自己的帳戶但使用其他郵件地址發送它,請使用SentOnBehalfOfName屬性。 那就是我通常所做的。

With olMail
Set olRecip = .Recipients.Add(Recip)
    ' chose either :
    .Sender = "anything@yourcompany.com"
    ' or
    .SentOnBehalfOfName = "anything@yourcompany.com"

暫無
暫無

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

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