78729883 78729883
关注数: 5 粉丝数: 43 发帖数: 1,907 关注贴吧数: 9
求助,vba用cdo接口发邮件,excel可以,word就发布出去 Sub CDOSENDEMAIL() Dim CDOMail As Variant On Error Resume Next '出错后继续执行 Application.DisplayAlerts = False '禁用系统提示 'Application.ChangeFileAccess Mode:=xlReadOnly '将工作簿设置为只读模式 报错,所以用了下面那一句 Application.DisplayDocumentInformationPanel = True Set CDOMail = CreateObject("CDO.Message") '创建对象 CDOMail.From = "*****" '设置发信人的邮箱 CDOMail.To = "******" '设置收信人的邮箱; CDOMail.Subject = "" '设定邮件的主题 CDOMail.HtmlBody = "" CDOMail.AddAttachment ThisDocument.fullname '发送本工作簿为附件,这一句一直报错 stUl = "http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fschemas.microsoft.com%2Fcdo%2Fconfiguration%2F&urlrefer=b014372b54864db334b644c63ef21832" '微软服务器网址 With CDOMail.Configuration.Fields .Item(stUl & "smtpserver") = "smtp.163.com" 'SMTP服务器地址 .Item(stUl & "smtpserverport") = 25 'SMTP服务器端口 .Item(stUl & "sendusing") = 2 '发送端口 .Item(stUl & "smtpauthenticate") = 1 '远程服务器需要验证 .Item(stUl & "sendusername") = "********" '发送方邮箱名称 .Item(stUl & "sendpassword") = "********" '发送方邮箱密码 .Item(stUl & "smtpconnectiontimeout") = 60 '连接超时(秒) .Update End With CDOMail.Send '执行发送 Set CDOMail = Nothing '发送成功后即时释放对象 If Err.Number = 0 Then MsgBox "成功发送邮件", , "温馨提示" '如果没有出错,则提示发送成功 Else MsgBox Err.Description, vbInformation, "邮件发送失败" '如果出错,则提示错误类型和错误代码 End If Application.DisplayDocumentInformationPanel = True 'Application.ChangeFileAccess Mode:=xlReadWrite '将工作簿设置为读写模式 ,报错,所以用了上面那一句 Application.DisplayAlerts = True '恢复系统提示 End Sub 感觉是CDOMail.AddAttachment ThisDocument.fullname 有问题 还有设置只读、读写 请帮忙看一下
1 下一页