1、核心代码
Dim objOutlook
Dim objOutMsg
Dim olMailItem
'Create the Outlook object and the new mail object.
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set mapi = objOutlook.GetNameSpace("MAPI")
'Define mail recipients
objOutlookMsg.To = "mengfeiyang@gpic.com"
'objOutlookMsg.CC = "my@email.com"
'objOutlookMsg.BCC = "my@email.com"
'Body of the message
objOutlookMsg.Subject = "QTP Test Mail"
objOutlookMsg.Body = "This is a test mail"
'Display the mail
objOutlookMsg.Display
'Send the message
objOutlookMsg.Send
'Release the objects
Set objOutlook = Nothing
Set mapi = Nothing
2、完整工程
代码直接导入UFT中即可。
https://yunpan.cn/cBVxDWBf3zRBN (提取码:cff6)