southwestgooner
Registered User.
- Local time
- Today, 08:30
- Joined
- May 14, 2009
- Messages
- 27
Hi All,
Hope your all having a good day.
This newbie to writing VB Code is in need of some help. I am a quick learner so hopefully this will add another string to my bow !
I have an automated email system (Lotus Notes) in a Access database I have created and am looking for the code needed to add up to 3 c.c addresses into an email prior to sending automatically.
The code I have to send the email to the To: individual is all working but can someone tell me what code I need to add and where for the c.c addresses of which there could be 1, 2 or 3. The control for To address is EmailTo = CustCopyEmail
The controls for the 3 c.c emails are cc_EmailAddress, cc_EmailAddress1 and cc_EmailAddress2.
Here's the code I have:
Private Sub SEND_CC_Click()
' Set up the objects required for Automation into Lotus Notes.
Dim Maildb As Object 'The mail database.
Dim Session As Object 'The Lotus Notes session.
Dim MailDoc As Object 'The mail document itself.
Dim UserName As String 'The current users Lotus Notes name.
Dim Subject As Object 'The message subject text.
Dim Body As Object 'The message body text.
Dim ECNNo As String 'The ECN No that has been updated.
Dim FullName As String 'The originars full name.
Dim EmailTo As Variant 'The email address of the originator or recipient.
' Set Email Address from form control.
EmailTo = CustCopyEmail
' Start a session to notes.
Set Session = CreateObject("Notes.NotesSession")
' Open the mail database in notes.
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
' Create the mail document.
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.ReplaceItemValue("Form", "Memo")
' Set the recipient.
Call MailDoc.ReplaceItemValue("SendTo", EmailTo)
' Set subject.
Call MailDoc.ReplaceItemValue("Subject", "Issue Sheet " & Me.M_IssSheetID & " actions required.")
' Create and set the Body content.
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Issue Sheet No " & Me.M_IssSheetID & " is available for your actions. Please view the Issue sheet and fill in any relevant required info. For your info the change(s) requested are '" & Me.ChangeGen & "'")
' Call Body.ADDNEWLINE(2)
' Call Body.EMBEDOBJECT(1454, "", "C:\filename", "Attachment")
' Example to save the message (optional).
MailDoc.SAVEMESSAGEONSEND = True
' Send the document.
Call MailDoc.ReplaceItemValue("PostedDate", Now())
' Gets the mail to appear in the Sent items folder.
Call MailDoc.SEND(False)
' Clean Up.
Set Maildb = Nothing
Set MailDoc = Nothing
Set Subject = Nothing
Set Body = Nothing
Set Session = Nothing
' Confirmation messages.
MsgBox "Message has been transferred to Notes and sent."
MsgBox "Check Lotus Notes inbox to ensure no delivery failure."
End Sub
Many thanks in anticipation of a swift resolution to this.
Cheers,
Steve.
Hope your all having a good day.
This newbie to writing VB Code is in need of some help. I am a quick learner so hopefully this will add another string to my bow !
I have an automated email system (Lotus Notes) in a Access database I have created and am looking for the code needed to add up to 3 c.c addresses into an email prior to sending automatically.
The code I have to send the email to the To: individual is all working but can someone tell me what code I need to add and where for the c.c addresses of which there could be 1, 2 or 3. The control for To address is EmailTo = CustCopyEmail
The controls for the 3 c.c emails are cc_EmailAddress, cc_EmailAddress1 and cc_EmailAddress2.
Here's the code I have:
Private Sub SEND_CC_Click()
' Set up the objects required for Automation into Lotus Notes.
Dim Maildb As Object 'The mail database.
Dim Session As Object 'The Lotus Notes session.
Dim MailDoc As Object 'The mail document itself.
Dim UserName As String 'The current users Lotus Notes name.
Dim Subject As Object 'The message subject text.
Dim Body As Object 'The message body text.
Dim ECNNo As String 'The ECN No that has been updated.
Dim FullName As String 'The originars full name.
Dim EmailTo As Variant 'The email address of the originator or recipient.
' Set Email Address from form control.
EmailTo = CustCopyEmail
' Start a session to notes.
Set Session = CreateObject("Notes.NotesSession")
' Open the mail database in notes.
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
' Create the mail document.
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.ReplaceItemValue("Form", "Memo")
' Set the recipient.
Call MailDoc.ReplaceItemValue("SendTo", EmailTo)
' Set subject.
Call MailDoc.ReplaceItemValue("Subject", "Issue Sheet " & Me.M_IssSheetID & " actions required.")
' Create and set the Body content.
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Issue Sheet No " & Me.M_IssSheetID & " is available for your actions. Please view the Issue sheet and fill in any relevant required info. For your info the change(s) requested are '" & Me.ChangeGen & "'")
' Call Body.ADDNEWLINE(2)
' Call Body.EMBEDOBJECT(1454, "", "C:\filename", "Attachment")
' Example to save the message (optional).
MailDoc.SAVEMESSAGEONSEND = True
' Send the document.
Call MailDoc.ReplaceItemValue("PostedDate", Now())
' Gets the mail to appear in the Sent items folder.
Call MailDoc.SEND(False)
' Clean Up.
Set Maildb = Nothing
Set MailDoc = Nothing
Set Subject = Nothing
Set Body = Nothing
Set Session = Nothing
' Confirmation messages.
MsgBox "Message has been transferred to Notes and sent."
MsgBox "Check Lotus Notes inbox to ensure no delivery failure."
End Sub
Many thanks in anticipation of a swift resolution to this.
Cheers,
Steve.