Originally Posted by
Kenneth Hobs
Look at the Session.Username part.
[vba]'Brian Walters, ozgrid.com, #67089
Sub SendLotusMail()
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim Session As Object 'The notes session
Dim Subject As String 'The subject string
Dim ReturnReceipt As String 'The ReturnReceipt string
Dim Recipient As String 'The Recipient string (or you could use the list)
Dim Recip(10) As Variant 'The Recipient list
Dim BodyText As String 'The body text
Dim SaveIt As Boolean 'Save to sent mail
Dim WasOpen As Integer 'Checking to see if the Mail DB was already
Subject = "Test Auto-generate"
Recipient = "anyone@yahoo.com"
SaveIt = True
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
WasOpen = 1 'Already open for mail
Else
WasOpen = 0
Maildb.OPENMAIL 'This will prompt you for password
End If
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = "Did it work?"
MailDoc.ReturnReceipt = "1"
MailDoc.SAVEMESSAGEONSEND = SaveIt
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
'Set AttachME = Nothing
'Set EmbedObj = Nothing
If WasOpen = 1 Then
Set Session = Nothing
ElseIf WasOpen = 0 Then
Set Session = Nothing
End If
Dim Msg, Style, Title, Help, Ctxt
Msg = "E-mail has been sent to " & Recipient & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Press OK to continue."
Style = vbOKOnly + vbInformation
Title = "Open Issues List"
MsgBox Msg, Style, Title, Help, Ctxt
End Sub
[/vba]