On Error GoTo ErrMsg: Screen.MousePointer = vbHourglass 'Dim App As Object 'Dim Itm As Object
'Set App = CreateObject("Outlook.Application") Dim o As New Outlook.Application Dim Itm As Outlook.MailItem 'Set Itm = o.CreateItem(0) Set Itm = o.CreateItem(olMailItem) With Itm .Subject = "a test email via vb!" .Recipients.Add ("c:\sn.txt") .To = "[email protected]" .Body = "test email about Outlook object - " & Now DoEvents '.Sensitivity = olPersonal .Send End With MsgBox "Sent successfully!", vbInformation, App.Title Screen.MousePointer = vbDefault Exit Sub ErrMsg: Screen.MousePointer = vbDefault MsgBox Err.Description, vbCritical, App.Title但还是会提示如何信息?通过OutLook2002自动发信,每次操作时Outlook都会跳出一个对话框,“A program is trying to automatically send e-mail using a Microsoft on your behalf. Do you want to allow this?” 因此每次都要手工点击“yes"才能继续。如何去掉呢?
'MAPI1. = mailsvr.Text
MAPI1.SessionID = MAPISession1.SessionID
MAPI1.MsgIndex = -1
MAPI1.RecipAddress = mailto.Text
'MAPI1.RecipDisplayName = mailto.Text
'MAPI1.MsgOrigAddress = mailfrom.Text '未啥只能读,对了,这是收到的信
'MAPI1.MsgOrigDisplayName = mailfrom.Text '发件人用OE默认,收信用fetch
MAPI1.MsgSubject = mailhead.Text
MAPI1.MsgNoteText = mailbody.Text
MAPI1.Send '0[缺省]不出现编辑框了,1出现编辑框! MAPISession1.SignOff
Screen.MousePointer = vbHourglass
'Dim App As Object
'Dim Itm As Object
'Set App = CreateObject("Outlook.Application")
Dim o As New Outlook.Application
Dim Itm As Outlook.MailItem
'Set Itm = o.CreateItem(0)
Set Itm = o.CreateItem(olMailItem)
With Itm
.Subject = "a test email via vb!"
.Recipients.Add ("c:\sn.txt")
.To = "[email protected]"
.Body = "test email about Outlook object - " & Now
DoEvents
'.Sensitivity = olPersonal
.Send
End With
MsgBox "Sent successfully!", vbInformation, App.Title
Screen.MousePointer = vbDefault
Exit Sub
ErrMsg:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbCritical, App.Title但还是会提示如何信息?通过OutLook2002自动发信,每次操作时Outlook都会跳出一个对话框,“A program is trying to automatically send e-mail using a Microsoft on your behalf. Do you want to allow this?”
因此每次都要手工点击“yes"才能继续。如何去掉呢?
还不明白的话,明天交流。
msn;[email protected]
随时在线。