jeffrey.demulling at usbank.com
jeffrey.demulling at usbank.com
Mon Feb 6 08:39:27 CST 2006
Dan, Here is some more code samples that may be of use for you. Make sure you set the references for Lotus Domino Objects and Lotus Notes Automation Classes. '--------------------------------------------------------------------------------------- ' Module : mdlSendLotusNotesMail ' DateTime : 2004-Mar-23 11:48 ' Author : Jeffrey F. Demulling ' Purpose : Used to send email via Lotus Notes. ' Notes : Orginal Code can be found at: http://www.fabalou.com/VBandVBA/lotusnotesmail.asp ' '--------------------------------------------------------------------------------------- Option Compare Database 'Public Sub SendNotesMail(Subject as string, attachment as string, 'recipient as string, bodytext as string,saveit as Boolean) 'This public sub will send a mail and attachment if neccessary to the 'recipient including the body text. 'Requires that notes client is installed on the system. Public Sub SendCTConnectionViaNotes(Subject As String, myrecipient As String, mySaveFlag As Boolean, mySendFromFlag As Integer) '--------------------------------------------------------------------------------------- ' Procedure : SendCTConnectionViaNotes ' DateTime : 2005-Apr-08 13:43 13:43 ' Author : Jeffrey F. Demulling ' Purpose : '--------------------------------------------------------------------------------------- ' 'Set up the objects required for Automation into lotus notes Dim maildb As NotesDatabase Dim MailDbName As String 'THe current users notes mail database name Dim MailDoc As NotesDocument Dim AttachME As Object 'The attachment richtextfile object Dim session As New NotesSession Dim MailDbDir As NotesDbDirectory Dim EmbedObj As Object 'The embedded object (Attachment) Dim strBodyText As String Dim db As DAO.Database Dim rst As DAO.Recordset Dim cmdtext As String Dim mysendfile As Variant Dim myServer As String Dim myFile As String Dim mymessage As String On Error GoTo SendCTConnectionViaNotes_Error 'Open the mail database in notes Select Case mySendFromFlag Case 2 myServer = GetPropertyValue("MarketingSharedEmailServer", setconnection) myFile = GetPropertyValue("MarketingSharedEmailFile", setconnection) session.Initialize Set maildb = session.GetDatabase(myServer, myFile) Case Else session.Initialize Set MailDbDir = session.GetDbDirectory("") Set maildb = MailDbDir.OpenMailDatabase() End Select If maildb.ISOPEN = True Then 'Already open for mail Else maildb.OPENMAIL End If 'Set up the new mail document Set MailDoc = maildb.CreateDocument MailDoc.ReplaceItemValue "Form", "Memo" MailDoc.ReplaceItemValue "Subject", Subject MailDoc.ReplaceItemValue "SendTo", myrecipient Select Case mySendFromFlag Case 2 'CT Shared MailDoc.ReplaceItemValue "Principal", GetPropertyValue("MarketingSharedEmailPrincipal", setconnection) 'MarketingSharedEmailPrincipal MailDoc.ReplaceItemValue "$INetPrincipal", GetPropertyValue("MarketingSharedEmail$INetPrincipal", setconnection) 'MarketingSharedEmail$INetPrincipal MailDoc.ReplaceItemValue "DisplayFrom", GetPropertyValue("MarketingSharedEmailDisplayFrom", setconnection) 'MarketingSharedEmailDisplayFrom MailDoc.ReplaceItemValue "DisplayFrom Preview", GetPropertyValue("MarketingSharedEmailDisplayFromPreview", setconnection) 'MarketingSharedEmailDisplayFromPreview Case Else 'Users 'Do Nothing End Select strBodyText = "Thank you for requesting that we send you the Corporate Trust Connection electronically. We are" strBodyText = strBodyText & " certain you will enjoy this edition. If you have any comments or future article" strBodyText = strBodyText & " suggestions, please respond to:" & vbCrLf & vbCrLf strBodyText = strBodyText & "marketing.corporatetrust at usbank.com" & vbCrLf & vbCrLf strBodyText = strBodyText & "NOTE: If you wish to remove your email address from this mailing, please reply to:" & cbCrLf strBodyText = strBodyText & " marketing.corporatetrust at usbank.com, including your name, organization and email address." strBodyText = strBodyText & " Please write REMOVE in the subject line." & vbCrLf & vbCrLf Set Body = MailDoc.CreateRichTextItem("Body") Body.AppendText strBodyText 'Place Attachments cmdtext = "SELECT" cmdtext = cmdtext & " TempFileList.FileName" cmdtext = cmdtext & " FROM" cmdtext = cmdtext & " TempFileList" cmdtext = cmdtext & " ORDER BY" cmdtext = cmdtext & " TempFileList.FileName;" Set db = CurrentDb Set rst = db.OpenRecordset(cmdtext) If Not rst.BOF And Not rst.EOF Then rst.MoveFirst Do Until rst.EOF mysendfile = rst.Fields("FileName") Set EmbedObj = Body.EmbedObject(EMBED_ATTACHMENT, "", mysendfile) rst.MoveNext Loop End If 'Send the document Select Case mySaveFlag Case True MailDoc.SaveMessageOnSend = True MailDoc.ReplaceItemValue "PostedDate", Now() MailDoc.Send (False) Case False MailDoc.SaveMessageOnSend = False MailDoc.Send (False) End Select 'Clean Up Set maildb = Nothing Set MailDoc = Nothing Set AttachME = Nothing Set session = Nothing Set MailDbDir = Nothing Set EmbedObj = Nothing On Error GoTo 0 Exit Sub SendCTConnectionViaNotes_Error: Select Case Err.Number Case -2147217504 mymessage = "Emails have not been sent for one of the following reasons:" & Chr(13) & Chr(10) mymessage = mymessage & "1: User canceled sending of email by canceling Lotus Notes password promt" & Chr(13) & Chr(10) mymessage = mymessage & "2: User is not an authorized user of the 'Marketing - Corporate Trust Shared' email box" MsgBox mymessage, vbCritical, "Action Cancelled" End Case Else MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SendCTConnectionViaNotes of Module mdlSendCTConnectionViaNotes" End Select End Sub Jeffrey F. Demulling Project Manager U.S. Bank Corporate Trust Services 60 Livingston Avenue EP-MN-WS3C St. Paul, MN 55107-2292 Ph: 651-495-3925 Fax: 651-495-8103 email: jeffrey.demulling at usbank.com "Dan Waters" <dwaters at usintern et.com> To Sent by: "'Access Developers discussion and accessd-bounces at d problem solving'" atabaseadvisors.c <accessd at databaseadvisors.com> om cc Subject 02/05/2006 11:28 Re: [AccessD] Lotus Notes Email - AM Thanks! Please respond to "Access Developers discussion and problem solving" <accessd at database advisors.com> Barb & Stuart! Thanks for this help. This is one of those 'could make the difference' items! Dan Waters -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Barbara Ryan Sent: Sunday, February 05, 2006 7:03 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Lotus Notes Email Dan...Yes --- here's some sample code http://www.fabalou.com/VBandVBA/lotusnotesmail.asp Barb Ryan ----- Original Message ----- From: "Dan Waters" <dwaters at usinternet.com> To: "AccessD" <accessd at databaseadvisors.com> Sent: Saturday, February 04, 2006 9:57 PM Subject: [AccessD] Lotus Notes Email > Has anyone used access to send email via Lotus Notes? I've never used Lotus > Notes for email or anything else, but a potential customer does, and I'd > like to tell him that I can connect to his email system. > > Thanks! > > Dan > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com ------------------------------------------------------------------------------ Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation. ==============================================================================