Solved

Email Missing Signature

Posted on 2007-11-27
20
775 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
20 Comments
 
LVL 84
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
 
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Save conflict messages on existing documents 15 46
Unrecognized Database Format 8 90
Alter an update query which rounds 7 30
how to link subforms ms/access VBA 6 26
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now