?
Solved

Email Missing Signature

Posted on 2007-11-27
20
Medium Priority
?
782 Views
Last Modified: 2013-12-18
I need the code below to add a signature.  I already have one stored in lotus notes, i'd like to use that one.   Also,  I need to attach a file and am not sure how to do that.   Lets say the path is the C Drive


Private Sub Command37_Click()
Dim rs As New ADODB.Recordset
 Dim strEmail As String
 
 Set Lotus2 = CreateObject("Notes.NotesSession")
 Set mailbox = Lotus2.GetDatabase("", "")
 mailbox.OPENMAIL
 Set msg = mailbox.CreateDocument
 msg.ReplaceItemValue "Form", "Memo"
 Set msgNoteText = msg.CreateRichTextItem("Body")
 
 
 If Format(Date - 1, "dddd") = "Sunday" Then
 
 msg.ReplaceItemValue "Subject", "AM Consolidated DSR" & " " & Date - 3
 
  msgNoteText.AppendText "Attached is the AM Consolidated DSR" & " " & Date - 3

 
 Else
 
 msg.ReplaceItemValue "Subject", "AM Consolidated DSR" & " " & Date - 1
 
  msgNoteText.AppendText "Attached is the AM Consolidated DSR" & " " & Date - 1
msg.ReplaceItemValue "Signature", "Signature"
 End If
 

 Set SendTo = msg.ReplaceItemValue("SendTo", "")
 
 rs.Open "tblAttendeeList", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
 
 Do While Not rs.EOF
   If Not IsNull(rs!Email) Then
     strEmail = rs!Email
     SendTo.AppendToTextList strEmail
   End If
   rs.MoveNext
 Loop
 
 rs.Close
 Set rs = Nothing
 
 msg.Save True, True
 CreateObject("Notes.NotesUiWorkspace").EDITDOCUMENT True, msg
 
End Sub


Thank you.

0
Comment
Question by:komskex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
20 Comments
 
LVL 85
ID: 20358128
I don't work with Lotus Notes, but in Outlook a Signature file is added by Outlook, and cannot be added through automation. That said, you can add the sig to the Body of the email, if desired.

I have no idea how to do an attachment in Lotus, sorry.

0
 
LVL 63

Expert Comment

by:SysExpert
ID: 20370965
In Lotus Notes, did you define an internal signature, or are you using an external file ?

If internal, you will need to find the docs ( probably a profile doc 0 and grab the text of the signature.

IN THIS CASE IT MAY BE easier to simply point it to an external file.

The signature only works by default, when you are using the UI classes, not the backend ones.



I hope this helps !
0
 

Author Comment

by:komskex
ID: 20373164
I'm not really sure what a UI class is ? I do have a signature stored in lotus notes.  Can you tell me more about UI Class ? Is it an easy fix for my code above ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:qwaletee
ID: 20378642
The short answer: see http://www.experts-exchange.com/Q_21069618.html#a11638305
The author is reputed to be reputable :)

The long answer:

There are about 25 lines of code in the Notes mail template that add the signature. You coudl copy those (template LotusScript is almost idnetical to VB).

Or, you could reinvent.

Either way, you could run into one problem. See, there are three ways a signature can be specified:
1) plain text, value is stored in mailbox/calendar profile
2) external HTML file, reference to filename is stored in mailbox/calendar profile
3) graphic (external GIF file), reference to filename is stored in mailbox/calendar profile

For #1, recreating the code is pretty trivial.

For #2/#3, it doesn;t use the Notes data API. It uses the client API, which actually controls the lcient very similarly to the menu structure. For #2/#3, it essetially invokes the code behind File>Import,HTML or File->Import,GIF. So you'll have todo the same.

Now that you understand all that, you can go back to the short answer and see what it does, then adapt it to VB. Just realize that all those Me. stuff are refering to a home-grown object, but that objects properties are really all just references to the mailbox, the mailbox/calendar profile, and the current (new) message
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20378799
Or, we could turn your code inside out. Instead of
- creating the "draft" message record with data
- and loading into the UI,

we can do it the other way around
- load a new empty memo in the UI
- manipulate the undelrying message record to populate the data

Advantage? New memos in the UI automatically load their signature, so that part is taken care of before we get to manipulating our own data.
0
 

Author Comment

by:komskex
ID: 20378846
Sorry i'm going to have to be spoon fed here, because nothing above is anything i understand.   I'll research UI when i get the chance.   Thank you.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20379538
How about this

Private Sub Command37_Click()
 
Dim rs As New ADODB.Recordset
 Dim strEmail As String
 
 Set Lotus2 = CreateObject("Notes.NotesSession")
 Set mailbox = Lotus2.GetDatabase("", "")
 mailbox.OPENMAIL
 
Set NotesUI = CreateObject("Notes.NotesUiWorkspace")
Set newMessage = NotesUI.ComposeDocument(mailbox.server,mailbox.filepath,"Memo")
newMessage.Save
 Set msg = newMessage.Document 'get access to the record represented on screen, isntead of just teh on-screen form
 Set msgNoteText = msg.getItem("Body")
 If Format(Date - 1, "dddd") = "Sunday" Then
 
 msg.ReplaceItemValue "Subject", "AM Consolidated DSR" & " " & Date - 3
 
  msgNoteText.AppendText "Attached is the AM Consolidated DSR" & " " & Date - 3
 
 
 Else
 
 msg.ReplaceItemValue "Subject", "AM Consolidated DSR" & " " & Date - 1
  
  msgNoteText.AppendText "Attached is the AM Consolidated DSR" & " " & Date - 1
 End If
 
 
 Set SendTo = msg.ReplaceItemValue("SendTo", "")
 
 rs.Open "tblAttendeeList", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
 
 Do While Not rs.EOF
   If Not IsNull(rs!Email) Then
     strEmail = rs!Email
     SendTo.AppendToTextList strEmail
   End If
   rs.MoveNext
 Loop
 
 rs.Close
 Set rs = Nothing
 
 msg.Save True, True
strEmail = msg.noteID 'save it so we can reopen it
newMessage.Close
Set msg = Nothing
'now that the record is completely out of the system, we can open it again so that all our changes actually display
Set msg = mailbox.getDocumentByID(strEmail) 'retrieve from disk again
NotesUI.EDITDOCUMENT True, msg 'and redisplay it
 
 
End Sub

Open in new window

0
 

Author Comment

by:komskex
ID: 20381992
Getting A type mismatch error from this line


 Set msgNoteText = msg.GETITEM("Body")
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20382179
That should be
Set msgNoteText = msg.getFirstItem("Body")
0
 

Author Comment

by:komskex
ID: 20382278
Getting Error Notes Error - This operation is not allowed whele a dialog box is displayed.  

Also the email list is not loading , or the subject or the body.  
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20382311
What line gives the error?
0
 

Author Comment

by:komskex
ID: 20383408

Sorry

NotesUI.EDITDOCUMENT True, msg 'and redisplay it

0
 

Author Comment

by:komskex
ID: 20383415
Automation Error
Object is not connected to server
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20399983
Replace
NotesUI.EDITDOCUMENT True, msg 'and redisplay it
 
With
Set draftMsg = mailbox.getDocumentByID(strEmail) 'retrieve from disk again
If draftMsg Is Nothing Then
  Msgbox "Unable to retrieve message " + strEmail + " form disk. Please find it at the end of your Drafts folder"
Else
  MsgBox "Successfully retrieved message " + strEmail + " form disk. Attempting to open it. If this fails, please find it at the end of your Drafts folder"
  NotesUI.EDITDOCUMENT True, draftMsg 'and redisplay it
End If
 

Set draftMsg = mailbox.getDocumentByID(strEmail) 'retrieve from disk again
If draftMsg Is Nothing Then
  Msgbox "Unable to retrieve message " + strEmail + " form disk. Please find it at the end of your Drafts folder"
Else
  MsgBox "Successfully retrieved message " + strEmail + " form disk. Attempting to open it. If this fails, please find it at the end of your Drafts folder"
  NotesUI.EDITDOCUMENT True, draftMsg 'and redisplay it
End If
 

Open in new window

0
 

Author Comment

by:komskex
ID: 20403681
I did the above and

The msg box pops up
Successfully retrived message b5a6  .......

I click ok

Then i get a Run time error 7412

Notes Error - This Operation is not allowed while a Dialog box is displayed

Then i hit debug
NotesUI.EDITDOCUMENT True, draftMsg 'and redisplay it
is highlighted




0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20408956
Was there actually a Notes dialog box displayed at that time?
0
 

Author Comment

by:komskex
ID: 20411126
What is a notes Dialog box ? I mean i had my calendar open and my inbox, that's it ?
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20411383
Like File->Database-Open, which opens a modal dialog box, or lilke File->Preferences->User preferences

When a modal dialog is open, you can't "click" on Notes.  The client UI is tied up. When this occurs, some of the external APIs are alos unavailable, particularly OLE Automation -- CreateObject("Notes.xxxxx"). Usually, COM objects -- CreateObject("Lotus.xxxxx") -- will succeed, because unlike the OLE interface, they communicate directly with the underlying API code, not using the client as an interface.
0
 

Author Comment

by:komskex
ID: 20411997
Nothing like that is Open so I don't really know what to say here ? Oh well.  Should i be referencing Lotus notes in access ? I am, just want to make sure if i should.  
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 500 total points
ID: 20417195
If you can, I would use Lotus.NotesSession instead of Notes.NotesSession. The only downside is that you may have to supply a password.

However, NotesuiDocument is ONLY available via Notes., not Lotus., because BY DEFINITION it has a user interface, which means it is using the lcinet, i.e., Notes, not an invisible API. As such, you need to use it with Notes.NotesSession.
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question