通过OutLook2002自动发信,每次操作时Outlook都会跳出一个对话框,“A program is trying to automatically send e-mail using a Microsoft on your behalf. Do you want to allow this?”因此每次都要手工点击“yes"才能继续。
如何去掉呢?我找了资料说下面这样写就可以了
Set ol = CreateObject("Outlook.Application")
Set Session = ol.Session
Set AL = ol.Session.AddressLists("Global Address List")
Set AE = AL.AddressEntries(1)
MsgBox AE.Address可执行『Set Session = ol.Session 』这句通不过吖。
怎么办?
如何去掉呢?我找了资料说下面这样写就可以了
Set ol = CreateObject("Outlook.Application")
Set Session = ol.Session
Set AL = ol.Session.AddressLists("Global Address List")
Set AE = AL.AddressEntries(1)
MsgBox AE.Address可执行『Set Session = ol.Session 』这句通不过吖。
怎么办?
Function CreateMail(astrRecip As Variant,strSubject As String, strMessage As String, Optional astrAttachments As Variant) As Boolean
Dim olApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim varRecip As Variant
Dim varAttach As Variant
Dim blnResolveSuccess As Boolean
On Error GoTo CreateMail_Err
Set olApp = New Outlook.Application
Set objNewMail = olApp.CreateItem(olMailItem)
With objNewMail
For Each varRecip In astrRecip
.Recipients.Add varRecip
Next varRecip
blnResolveSuccess = .Recipients.ResolveAll
For Each varAttach In astrAttachments
.Attachments.Add varAttach
Next varAttach
.Subject = strSubject
.Body = strMessage
If blnResolveSuccess Then
.Send
Else
MsgBox "Unable to resolve all recipients. Please check the names."
.Display
End If
End With
CreateMail = True
CreateMail_End:
Exit Function
CreateMail_Err:
CreateMail = False
Resume CreateMail_End
End Function
救命啊!