I have sourced much code of the internet to be able to send e-mails via lotus notes from excel, although the code is likely to be very crude it seems to work fine apart from 2 small issues that i hope someone might be able to offer me guidance on.
The issues are:
1: In the sent items folder, no name appears in the recipient column even though everyone has received the e-mail and i can see their names if i open the e-mail.
2. If a user has an image signature rather than the standard text then my code just identifies where the image is saved rather than displaying the image.
Many Thanks in advance
--------------------------------------------------------------------------------------------------------------------
Dim Rec As String, vaRecipient() As String, ccRecipient() As String
Public stMsg As String
Public stTitle As String
Public stAttachment As String
Public stSubject As String
Public noSession
Public noDatabase
Public noDocument
Public Signature As String
Public obAttachment As Object, EmbedObject As Object
Public NoAttachment As Object
Const EMBED_ATTACHMENT As Long = 1454
Sub SendEmail()
On Error GoTo ErrorMessage1
' add reipients, CC, Subject and Message
Call Add_Recipients
Call Add_CC
Call Add_Subject
Call Add_Message
'add extra comments in
SenderName = InputBox("Insert your name, which will be added to the end of your e-mail." & vbNewLine & vbNewLine & "Press cancel to stop the e-mail", "Name")
If StrPtr(SenderName) = 0 Then
End
End If
'Instantiate the Lotus Notes COM's Objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
On Error Resume Next
'Attach Your Signature
Signature = noDatabase.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
On Error GoTo ErrorMessage1
'Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.SendTo = vaRecipient
.copyto = ccRecipient
.Subject = stSubject
.Body = "Please see attached" & vbNewLine & vbNewLine & "Regards" & vbNewLine & vbNewLine & SenderName & vbNewLine & vbNewLine & Signature
.SAVEMESSAGEONSEND = True
End With
'Send the e-mail.
With noDocument
.PostedDate = Now()
.Send 0, vaRecipient
End With
On Error GoTo ErrorMessage2
'Release objects from the memory.
Set EmbedObject = Nothing
Set obAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
End sub
The issues are:
1: In the sent items folder, no name appears in the recipient column even though everyone has received the e-mail and i can see their names if i open the e-mail.
2. If a user has an image signature rather than the standard text then my code just identifies where the image is saved rather than displaying the image.
Many Thanks in advance
--------------------------------------------------------------------------------------------------------------------
Dim Rec As String, vaRecipient() As String, ccRecipient() As String
Public stMsg As String
Public stTitle As String
Public stAttachment As String
Public stSubject As String
Public noSession
Public noDatabase
Public noDocument
Public Signature As String
Public obAttachment As Object, EmbedObject As Object
Public NoAttachment As Object
Const EMBED_ATTACHMENT As Long = 1454
Sub SendEmail()
On Error GoTo ErrorMessage1
' add reipients, CC, Subject and Message
Call Add_Recipients
Call Add_CC
Call Add_Subject
Call Add_Message
'add extra comments in
SenderName = InputBox("Insert your name, which will be added to the end of your e-mail." & vbNewLine & vbNewLine & "Press cancel to stop the e-mail", "Name")
If StrPtr(SenderName) = 0 Then
End
End If
'Instantiate the Lotus Notes COM's Objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
On Error Resume Next
'Attach Your Signature
Signature = noDatabase.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
On Error GoTo ErrorMessage1
'Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.SendTo = vaRecipient
.copyto = ccRecipient
.Subject = stSubject
.Body = "Please see attached" & vbNewLine & vbNewLine & "Regards" & vbNewLine & vbNewLine & SenderName & vbNewLine & vbNewLine & Signature
.SAVEMESSAGEONSEND = True
End With
'Send the e-mail.
With noDocument
.PostedDate = Now()
.Send 0, vaRecipient
End With
On Error GoTo ErrorMessage2
'Release objects from the memory.
Set EmbedObject = Nothing
Set obAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
End sub