ActiveSheet.MailEnvelope

2019-09-02 20:20发布

have been trying to send email with vba , but i ran in to an unusual problem with the mail envelope, and have seen lots of unanswered problems with this delicate object.

I have discovered through debugging that it locks up when trying to send following code, one problem i resolved was that I needed a range to be selected.

BUT now it is locking up cos i am sending a message with the from field empty.

if i add a break point, add the field manually then resume all goes well,

but i cannot find the proper syntax to do this: .Item.From = "me@email.com"

ActiveWorkbook.EnvelopeVisible = True

'    On Error Resume Next

With ActiveSheet.MailEnvelope
    .Item.To = tech
    .Item.Subject = "some words"
    .Introduction = "some more words"
    ActiveSheet.Range("A1:G5").Select

                 //           from line goes here

    .Send

End With

ActiveWorkbook.EnvelopeVisible = False
On Error GoTo 0

1条回答
太酷不给撩
2楼-- · 2019-09-02 20:38

".From" is .SentOnBehalfOfName

.SentOnBehalfOfName = "me@email.com"

https://msdn.microsoft.com/en-us/library/office/ff862145.aspx

查看更多
登录 后发表回答