ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 14202|回复: 12

在EXCEL里面调用LOTUS NOTES发邮件

[复制链接]

TA的精华主题

TA的得分主题

发表于 2005-7-26 10:32 | 显示全部楼层 |阅读模式

各位高手哥哥/姐姐,在EXCEL里面如何调用LOTUS NOTES发邮件呢? 将已经打开的该EXCEL工作簿作为该邮件的附件.  谢谢指点

TA的精华主题

TA的得分主题

发表于 2005-7-26 11:00 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

用excel自动打开notes倒是可以的,发邮件恐怕不行

Dim RetVal On Error Resume Next RetVal = Shell("C:\Lotus\Notes\notes.exe", 1) Do While True AppActivate RetVal If Err <> 0 Then Exit Do Loop AppActivate RetVal Application.SendKeys "password" Application.SendKeys "{enter}"

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-7-26 13:21 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

大哥啊,可是用OUTLOOK是可以直接将一个打开的EXCEL文件作为附件发出去的啊,

可否帮我想想办法. LOTUS NOTE 是否可以作为一个对象来调用呢?

TA的精华主题

TA的得分主题

发表于 2005-7-26 13:47 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

这个我就不知道了,用notes的人很少的,你的问题危险了

TA的精华主题

TA的得分主题

发表于 2005-7-26 13:53 | 显示全部楼层
在IE浏览器的工具-INTERNET选项-程序页-将"电子邮件"的打开程序改为"LOTUS NOTES"即可.试试吧.

TA的精华主题

TA的得分主题

发表于 2006-2-22 12:14 | 显示全部楼层
有谁测试过FeiHong的代码? 我没有运行环境,但非常想知道测试结果.

TA的精华主题

TA的得分主题

发表于 2006-2-22 20:12 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-3-5 23:14 | 显示全部楼层
在VBA中用Lotus發郵件
		
Sub SendWithLotus()
    Dim noSession    As Object
    Dim noDatabase   As Object
    Dim noDocument   As Object
    Dim noAttachment As Object
    Dim vaFiles      As Variant
    Dim i            As Long
    Const EMBED_ATTACHMENT = 1454
    Const stSubject  As String = "文件發送測試"
    Const stMsg      As String = "This File Is For You! Just For Reference" & _
                                 vbCrLf & "I am PC-6"
    Dim vaRecipient As Variant
    vaRecipient = VBA.Array("danis@3126.com", "rockylee@3126.com")
    vaFiles = Application.GetOpenFilename(FileFilter:="Excel Filer (*.xls),*.xls", _
              Title:="Attach files for outgoing E_Mail", MultiSelect:=True)
    If Not IsArray(vaFiles) Then Exit Sub
    'Insert Lotus Notes COM object.
    Set noSession = CreateObject("Notes.NotesSession")
    Set noDatabase = noSession.GetDataBase("", "")
    If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
    Set noDocument = noDatabase.CreateDocument
    Set noAttachment = noDocument.CreateRichTextItem("Body")
    'Set noAttachment = noDocument.CreateRichTextItem("Body1")
    With noAttachment
         For i = 1 To UBound(vaFiles)
             .EmbedObject EMBED_ATTACHMENT, "", vaFiles(i)
         Next i
    End With
    With noDocument
         .Form = "Memo"
         .SendTo = vaRecipient
         .Subject = stSubject
         .Body = stMsg
         .SaveMessageOnSend = True
         .PostedDate = Now() - 100
         .Send 0, vaRecipient
    End With
    Set noDocument = Nothing
    Set noDatabase = Nothing
    Set noSession = Nothing
    AppActivate "Microsoft Excel"
    MsgBox "This file is send  OK", vbInformation
End Sub

TA的精华主题

TA的得分主题

发表于 2005-7-26 20:11 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

还有一个:

Function SendNotesMail(strMessage As String, _ strSubject As String, _ strSendTo As String, _ lngLogo As Long, strAttachment As String) On Error GoTo NotesMail_Err Dim lnSession As Object Dim lnDatabase As Object Dim lnDocument As Object Dim lnRTStyle As Object Dim lRTItem As Object Dim lnATTACHMENT As Object Dim sMessage As String Dim lLogo As Long ''start a notes session... Set lnSession = CreateObject("Notes.Notessession") ''create a new style object to control t ' ' he appearance of the message Set lnRTStyle = lnSession.CreateRichTextStyle ''get the current database... Set lnDatabase = lnSession.GetDatabase("", "") lnDatabase.OpenMail ''create a new document Set lnDocument = lnDatabase.CreateDocument ''create a new NotesRichTextItem object ' in which we can store, ''and format the main message body in Ri ' ' chText format Set lnRTItem = lnDocument.CreateRichTextItem("Body")

If strAttachment <> "" Then Set lnATTACHMENT = lnRTItem.EMBEDOBJECT _ (1454, "", strAttachment, "Sample") End If sMessage = "Mail sent: " & Date & " " & Time & vbCrLf & vbCrLf & _ strMessage ''format the message lnRTStyle.NotesFont = 4 ''Courier lnRTStyle.Bold = True lnRTStyle.NotesColor = 2 ''red Call lnRTItem.AppendStyle(lnRTStyle) Call lnRTItem.AppendText(sMessage) 'Call lnRTItem.AddNewLine(1) ''logo values are between 0 and 31 lLogo = lngLogo

If lLogo < 0 Or lLogo > 31 Then lLogo = 0 End If ''replace some of the fields that we nee ' ' d...

With lnDocument ''who we want to send to... ''recipient .ReplaceItemValue "SendTo", strSendTo ''subject .ReplaceItemValue "Subject", strSubject ''body - non RichText '.ReplaceItemValue "Body", "The body of ' the message!" ''set the logo! (letter head) .ReplaceItemValue "Logo", "StdNotesLtr" & Trim$(Str$(lLogo)) ''send the message .Send False End With Set lRTItem = Nothing Set lnRTStyle = Nothing Set lnDocument = Nothing Set lnDatabase = Nothing Set lnSession = Nothing MsgBox "Mail was sent!", vbInformation, _ strSendTo Exit Function NotesMail_Err: MsgBox Err.Description, _ vbExclamation, _ "Send mail error! (" & Trim$(Str$(Err)) & ")" End Function

Function Test_note() SendNotesMail "Hello! This is an email message! with an attachment", _ "Test Lotus Notes Email - Attachment test", _ "youraddress@work", 0, "C:\autoexec.bat" End Function

TA的精华主题

TA的得分主题

发表于 2005-7-26 20:04 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

没测试环境,你看看:

Public Const SW_HIDE = 0 Public Const SW_NORMAL = 1 Public Const SW_SHOWMINIMIZED = 2 Public Const SW_SHOWMAXIMIZED = 3 Public Const SW_SHOWNOACTIVATE = 4 Public Const SW_SHOW = 5 Public Const SW_MINIMIZE = 6 Public Const SW_SHOWMINNOACTIVE = 7 Public Const SW_SHOWNA = 8 Public Const SW_RESTORE = 9 Public Const SW_SHOWDEFAULT = 10 'API functions to enumerate and set the ' desired forground window Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long Declare Function SetActiveWindow Lib "user32.dll" (ByVal hWnd As Long) As Long Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long 'This function will go through all windo ' ws currently running 'Once Lotus Notes window handle is found ' , it will make it the 'foreground window and exit the function ' Public Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Boolean Dim sSave As String, Ret As Long Ret = GetWindowTextLength(hWnd) sSave = Space(Ret) GetWindowText hWnd, sSave, Ret + 1 If InStr(1, sSave, "Lotus Notes") > 0 Then retval = SetForegroundWindow(hWnd) Call ShowWindow(hWnd, SW_SHOWMAXIMIZED) Exit Function End If 'continue enumeration EnumWindowsProc = True End Function 'End Module Code Segment '*************************************** ' 'Begin "ThisDocument" Code Segment '*************************************** ' Const cmdBarText = "Create Email Document" Const cmdAction = "emailMe" Const tagName = "EM" Private Sub Document_Close() On Error Resume Next For i% = 1 To Application.CommandBars.Count - 1 If InStr(1, Application.CommandBars(i%).Name, "Create Mail Memo") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Email") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Email Document") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Create Email Document") Then ThisDocument.CommandBars(i%).Delete ThisDocument.CommandBars(i%).Visible = False End If Next Dim cmd As Office.CommandBarControl Set cmd = Application.CommandBars.FindControl(Tag:=tagName) Do While Not cmd Is Nothing cmd.Delete Set cmd = Application.CommandBars.FindControl(Tag:=tagName) Loop End Sub Private Sub Document_New() On Error Resume Next For i% = 1 To Application.CommandBars.Count If InStr(1, Application.CommandBars(i%).Name, "Create Mail Memo") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Email") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Email Document") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Create Email Document") Then ThisDocument.CommandBars(i%).Delete ThisDocument.CommandBars(i%).Visible = False End If Next Set eBut = ThisDocument.CommandBars.Add(Name:=cmdBarText) With ThisDocument.CommandBars(cmdBarText) .Position = msoBarTop .Visible = True End With Set custBar = Application.CommandBars(cmdBarText).Controls.Add With custBar .Caption = cmdBarText .Style = msoButtonCaption .OnAction = cmdAction .Tag = tagName End With End Sub Private Sub Document_Open() On Error Resume Next For i% = 1 To Application.CommandBars.Count - 1 If InStr(1, Application.CommandBars(i%).Name, "Create Mail Memo") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Email") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Email Document") > 0 _ Or InStr(1, Application.CommandBars(i%).Name, "Create Email Document") Then ThisDocument.CommandBars(i%).Delete End If Next Set eBut = ThisDocument.CommandBars.Add(Name:=cmdBarText) With ThisDocument.CommandBars(cmdBarText) .Position = msoBarTop .Visible = True End With Set custBar = Application.CommandBars(cmdBarText).Controls.Add With custBar .Caption = cmdBarText .Style = msoButtonCaption .OnAction = cmdAction .Tag = tagName End With End Sub Sub emailMe() MsgBox ThisDocument.Application.Version Dim WK As Object Dim lnS As Object Dim lnDB As Object Dim lnDoc As Object Dim lnDoc2 As Object Dim lnRT As Object Dim bd2 As Object Dim cUNID As String Dim file As String If ActiveDocument.Saved = False Then ActiveDocument.Save End If file = Word.ActiveDocument.FullName Set lnS = CreateObject("Notes.NotesSession") Set lnDB = lnS.GETDATABASE("", "") Call lnDB.OPENMAIL Set lnDoc = lnDB.createdocument Set lnRT = lnDoc.createrichtextitem("Body") With lnRT Call .ADDNEWLINE(1) Call .APPENDTEXT("This is a test") Call .ADDNEWLINE(2) Call .APPENDTEXT("Below is your attachment: " & file) Call .ADDNEWLINE(1) Call .APPENDTEXT(String(50, "-")) Call .ADDNEWLINE(2) End With 'Attach the file Set bd2 = lnRT.EMBEDOBJECT(1454, "", file) cUNID = lnDoc.UNIVERSALID Call lnDoc.Save(True, True) Set lnDoc2 = lnDB.GETDOCUMENTBYUNID(cUNID) Set WK = CreateObject("Notes.NotesUIWorkspace") Call WK.EDITDOCUMENT(True, lnDoc2) Set WK = Nothing Set lnS = Nothing Set lnDB = Nothing Set lnDoc = Nothing Set lnDoc2 = Nothing Set lnRT = Nothing Set bd2 = Nothing 'Go through all processes (windows) unti ' l we get Lotus Notes 'Once we get LN Address, make it the act ' ive window 'The AddressOf operater id not supported ' in Office97 EnumWindows AddressOf EnumWindowsProc, ByVal 0& End Sub

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-12-31 04:03 , Processed in 1.035911 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表