B
Beeyen
Hello Everyone,
I have Lotus Notes version 7.03 which I used through a network, so it has
global addresses. I have a db, in which I have three combo boxes Production
Assigned, QandALead and Router. The names selected in the combo boxes are in
the global addresses book but also the third column has the .com email
address. For some reason the Session will not Initialize when I click on the
command button my biggest problem.
In addition I am trying to:
1. Have the combo box with the Router name placed in the From: field of
Lotus
The Production Assigned and QandALead name placed in the To: field of Lotus
2. Allow for editing a standard txtmsg in the body of the mail message.
3. Link a field in the mainform, controlname DatatrakNumber which
shows in the Subject: field.
I was hoping someone with lotus notes and access expertise could give me a
hand.
Thanks
Private Sub Email_Assigned_Click()
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 AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your
password
Session.Initialize ("password")
'Get the sessions username and then calculate the mail file name
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
'Set MailDoc = Maildb.CREATEDOCUMENT
'rem MailDoc.Form = "Memo"
'MailDoc.sendto = Recipient
'MailDoc.Subject = Subject
'MailDoc.Body = BodyText
'MailDoc.SAVEMESSAGEONSEND = SaveIt
NotesMailDoc.SAVEMESSAGEONSEND = True
NotesMailDoc.SendTo = Me.ProductionAssigned.Column(3)
NotesMailDoc.from = Notesession.UserName
NotesMailDoc.Subject = "Production Assigned"
NotesMailDoc.Body = Me.txtmsg
NotesMailDoc.SEND
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment,
"Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
I have Lotus Notes version 7.03 which I used through a network, so it has
global addresses. I have a db, in which I have three combo boxes Production
Assigned, QandALead and Router. The names selected in the combo boxes are in
the global addresses book but also the third column has the .com email
address. For some reason the Session will not Initialize when I click on the
command button my biggest problem.
In addition I am trying to:
1. Have the combo box with the Router name placed in the From: field of
Lotus
The Production Assigned and QandALead name placed in the To: field of Lotus
2. Allow for editing a standard txtmsg in the body of the mail message.
3. Link a field in the mainform, controlname DatatrakNumber which
shows in the Subject: field.
I was hoping someone with lotus notes and access expertise could give me a
hand.
Thanks
Private Sub Email_Assigned_Click()
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 AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your
password
Session.Initialize ("password")
'Get the sessions username and then calculate the mail file name
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
'Set MailDoc = Maildb.CREATEDOCUMENT
'rem MailDoc.Form = "Memo"
'MailDoc.sendto = Recipient
'MailDoc.Subject = Subject
'MailDoc.Body = BodyText
'MailDoc.SAVEMESSAGEONSEND = SaveIt
NotesMailDoc.SAVEMESSAGEONSEND = True
NotesMailDoc.SendTo = Me.ProductionAssigned.Column(3)
NotesMailDoc.from = Notesession.UserName
NotesMailDoc.Subject = "Production Assigned"
NotesMailDoc.Body = Me.txtmsg
NotesMailDoc.SEND
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment,
"Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub