【问题标题】:How to open a Lotus Notes New mail and send如何打开 Lotus Notes 新邮件并发送
【发布时间】:2016-11-07 09:38:44
【问题描述】:

我见过几个用于加载 Lotus Notes 并将附件放入并发送出去的宏。 它几乎完成了它发送电子邮件,但不知道如何发送文件夹,它适用于 PDF 文件,但我要发送的文件夹中有一堆 PDF 文件。 我如何格式化电子邮件以阅读: " 你好

请找附件

(附件)

签名 "

感谢任何帮助,谢谢

 Sub SendEmail()
 Dim WatchRange As Range
 Dim IntersectRange As Range
Dim x As Integer
Dim UserName As String
Dim MailDbName As String
Dim Recipient As Variant
Dim Maildb As Object
Dim MailDoc As Object
Dim Attachment As String
Dim Session As Object
Dim stSignature As String
With Application
.ScreenUpdating = False
.DisplayAlerts = False
' Open and locate current LOTUS NOTES User
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1,           UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
' Create New Mail and Address Title Handlers
 Set MailDoc = Maildb.CREATEDOCUMENT
 MailDoc.Form = "Memo"
 Maildb.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
' Select range of e-mail addresses
 MailDoc.SendTo = "joe bloggs"
 MailDoc.subject = "Work"
 MailDoc.Body = "Hello" & " " & " Please find attachment."
 MailDoc.SAVEMESSAGEONSEND = True
 Attachment = "c:\03-11\4267.pdf"
 If Attachment <> "" Then

    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "")
    On Error Resume Next
    MailDoc.CREATERICHTEXTITEM ("Attachment")
End If

  MailDoc.PostedDate = Now()
  On Error GoTo errorhandler1
 MailDoc.SEND 0, Recipient
 Set Maildb = Nothing
 Set MailDoc = Nothing
 Set Session = Nothing
 .ScreenUpdating = True
 .DisplayAlerts = True
  On Error GoTo errorhandler1
  Set Maildb = Nothing
  Set MailDoc = Nothing
  Set Session = Nothing
 End With
 End Sub

我已经修改了我的宏,它现在添加了签名,但是格式错误并且它没有附加文件。

    Sub SendEmail()

  Dim WatchRange As Range
  Dim IntersectRange As Range
  Dim x As Integer
  Dim UserName As String
  Dim MailDbName As String
  Dim Recipient As Variant
 Dim Maildb As Object
 Dim MailDoc As Object
 Dim Attachment As String
 Dim Session As Object
  Dim stSignature As String
 Dim ws As Object 'Lotus Workspace


  Dim objProfile As Object
  Dim rtiSig As Object, rtitem As Object, rtiNew As Object
  Dim uiMemo As Object
  Dim strToArray() As String, strCCArray() As String, strBccArray() As String
 Dim strTo As String, strCC As String, strBcc As String, _
 strObject As String, strBody As String, strAttachment As String, blnSaveit As   Boolean
   Dim strSignText As String, strMemoUNID As String
   Dim intSignOption As Integer


  With Application
  .ScreenUpdating = False
   .DisplayAlerts = False
   ' Open and locate current LOTUS NOTES User
   Set Session = CreateObject("Notes.NotesSession")
   Set ws = CreateObject("Notes.NotesUIWorkspace")

   UserName = Session.UserName
     MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Maildb.IsOpen = True Then
    Else
     Maildb.OPENMAIL
    End If
    ' Create New Mail and Address Title Handlers


    Set MailDoc = Maildb.CREATEDOCUMENT
     MailDoc.Form = "Memo"
   stSignature =                        Maildb.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
  ' Select range of e-mail addresses
    MailDoc.SendTo = "JJunoir"
     MailDoc.subject = ""
     MailDoc.Body = "Hello" & " " & " Please find attachment,"
      MailDoc.SAVEMESSAGEONSEND = True


      Set objProfile = Maildb.GETPROFILEDOCUMENT("CalendarProfile")
      intSignOption = objProfile.GETITEMVALUE("SignatureOption")(0)
      strSignText = objProfile.GETITEMVALUE("Signature")(0)


      Attachment = "c:\Debit Notes 03-11\"
     If strAttachment <> "" Then
    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", strAttachment,     "Attachment")
    On Error Resume Next
    MailDoc.CREATERICHTEXTITEM ("Attachment")
    End If


   'Open memo in ui
   Set uiMemo = ws.EDITDOCUMENT(True, MailDoc)
   Call uiMemo.GotoField("Body")

   'Check if the signature is automatically inserted
   If objProfile.GETITEMVALUE("EnableSignature")(0) <> 1 Then
   If intSignOption = 2 Then
   Call uiMemo.ImportItem(objProfile, "Signature_Rich")
    End If
    End If

   Call uiMemo.GotoField("Body")
   'Save the mail doc
   strMemoUNID = uiMemo.DOCUMENT.UNIVERSALID
    uiMemo.DOCUMENT.MailOptions = "0"
   Call uiMemo.Save
   uiMemo.DOCUMENT.SaveOptions = "0"
   Call uiMemo.Close
   Set uiMemo = Nothing
   Set MailDoc = Nothing

   'Get the text and the signature
   Set MailDoc = Maildb.GETDOCUMENTBYUNID(strMemoUNID)
   Set rtiSig = MailDoc.GETFIRSTITEM("Body")
   Set rtiNew = MailDoc.CREATERICHTEXTITEM("rtiTemp")
   Call rtiNew.APPENDTEXT(strBody)
   Call rtiNew.APPENDTEXT(Chr(10)): Call rtiNew.APPENDTEXT(Chr(10))
   Call rtiNew.APPENDRTITEM(rtiSig)
  'Remove actual body to replace it with the new one
  Call MailDoc.RemoveItem("Body")
  Set rtitem = MailDoc.CREATERICHTEXTITEM("Body")
  Call rtitem.APPENDRTITEM(rtiNew)

  MailDoc.Save False, False
  Set uiMemo = ws.EDITDOCUMENT(True, MailDoc)


   MailDoc.PostedDate = Now()
   On Error GoTo errorhandler1
   MailDoc.SEND 0, Recipient
   Set Maildb = Nothing
   Set MailDoc = Nothing
   Set Session = Nothing
  .ScreenUpdating = True
  .DisplayAlerts = True
  errorhandler1:
  Set Maildb = Nothing
  Set MailDoc = Nothing
  Set Session = Nothing
  End With
  End Sub

这是它没有附件的结果 亲切的问候 J Junior你好,请找附件,

【问题讨论】:

  • 我已将之前的宏更新为这个新的宏。谁能解释这一行 Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment") Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "")
  • 现在添加一个换行 MailDoc.Body = "Hello" & vbNewLine & vbNewLine & " Please find attachment," & vbNewLine。我仍在尝试寻找添加签名的解决方案。

标签: excel macros lotus-notes lotus-domino


【解决方案1】:

如果您的目标是操作 Lotus Notes 客户端用户界面,那么您使用“Notes.NotesSession”而不是“Lotus.NotesSession”开始了一半。笔记。”前缀为您提供OLE classes,而不是您使用“Lotus”前缀获得的 COM 类,并且您肯定需要使用 OLE 类 - 但您仍然选择了错误的根对象。

OLE 和 COM 类中都可用的 NotesSession 类及其派生类被称为“后端类”,这意味着它们根本不操纵用户界面。

如果要操作 UI,则需要使用“前端类”,而根对象是“Notes.NotesUIWorkspace”。在许多情况下,您可能会发现您需要后端类和前端类的组合。例如,NotesUIWorkspace.EditDocument(前端)采用 NotesDocument(后端)参数,允许您通过在后台找到它来打开您找到的文档的 UI。

【讨论】:

  • 现在它不适用于 Line Username=Session.Username。运行时错误 438。对象不正确支持这一点。我可以把它改成什么?
  • 如果您需要/想要同时使用 UI 类(操作用户界面)和后端类(从 NotesSession 对象获取用户名),您需要对两者进行实例化。
  • 您现在使用哪个会话类? Notes.NotesSesison 还是 Lotus.NotesSession?您是否尝试过使用他们两个的 Username 属性?
  • Richard,我现在已经完全改变了我的宏,但是上面的问题现在已经解决了。
  • 让 StackOverflow 这样的社区运作的基本原则之一是,如果您向他人寻求帮助,然后解决了您的问题,您应该愿意分享您如何解决问题的详细信息以便其他人可以从您的经验中学习。请考虑发布您自己对问题的答案,描述您如何解决问题并包含更新的代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-04
  • 1970-01-01
  • 2014-08-06
  • 1970-01-01
  • 2015-10-25
  • 1970-01-01
  • 2013-04-11
相关资源
最近更新 更多