Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an email from Access/Notes

Status
Not open for further replies.

menstroy

MIS
Jun 2, 2003
63
US
Hello,

I've see a lot of code on how to send email from Access through Lotus notes, but I have a simpler request...

I have a phone book inside access and I want to be able when a command button is pressed to send an email

1. Load notes if not
2. Start New email
3. place reciptiants names in list
4. Leave the message open for editing...

Step 4 is the key, everything I've seen has the code automaticly sending the email, I want to leave the message open so the user can then type the subject and message on their own.

Thanks!
 
Hi

The "Send to" will launch Notes if its not open and of course it a "New Mail" screen, so thats the first two points covered. It might be harder to it to put the recipient in there thow. It does leave the email open for editing, so you can add text etc.
You will need to have a play around....

Regards

David
 
I finaly got it to work, but how do I have access bring the lotus notes window to the front? I want to make it visible or set focus?

Thanks
 
Mestroy,

Can you please post your code example here? New to Lotus Notes...

Thank you,

DH
 
Below is the code I found on the net that I was able to utilize to send mail from Access/VB.

------------------------------------------------------
Option Compare Database
Public Declare Function GetUserNameAPI Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Public adminaccess As String

'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 SendNotesMail(Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
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
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other mailboxes.
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
MailDoc.Form = "Memo"
MailDoc.SendTo = Recipient
MailDoc.Subject = Subject
MailDoc.body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
'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

Public Function LetterA_Click()
GroupSelect.Value = 1
LastName.SetFocus
LastName.Text = ""
SendKeys "A"
End Function


Public Function GetUserName() As String
Dim sBuffer As String
Dim lSize As Long

' Space for dll parameters
sBuffer = Space$(255)
lSize = Len(sBuffer)

Call GetUserNameAPI(sBuffer, lSize)

If lSize > 0 Then
' Remove empty spaces
GetUserName = Left$(sBuffer, lSize)
Else
' Return empty if no user is found
GetUserName = vbNullString
End If

End Function
 
menstroy,

Thanks for the code example. I have it working and have one question:

1.) I would like to make the mail format HTML, for example, in Outlook I can set the format using session.HTMLBody is there something simialar to this in lotus notes to force the mail format/body format to be HTML?

DH
 
How could the following be accomplished:

After email is sent:

1.) Close Lotus Notes if it wasn't already open.

If it wasn't already open I end of with an empty shell of lotus notes and I would like to close it if the user didn't previously have it open.

By the way is there any way to prior to sending have the email created within lotus notes and display it for the user to edit and manually send?

Thanks a million.

DH
 
I would like to be able to query an Access database then output the e-mail addresses of people that meet the criteria in the bcc field(or send to) in Lotus Notes. I am not an IT pro. Is this difficult to do? Does anybody have any suggestions? Do you know of any resources that I could read to get up to speed on this subject? Your response is appreciated.
 
sundet,

Search Forum705 Access VBA for Lotus Notes and you'll find some examples, here are a few:

Thread705-394014
Thread705-844818
Thread705-832624




Leslie
 
When I use the code supplied above I get a run time error on the code: Session.Initialize("Put My Password Here").
The exact error is: Run-time error '438': Object doesn't support this property method. Can any one help me out? Thanks in advance!
 
Here's the Help on the Initialize method:

Initializes a COM session with the current user ID.
Note This method is new with Release 5.0.2b.
Note This method is supported in COM only.
Defined in
NotesSession
Syntax
Call notesSession.Initialize( [ password$ ] )
Parameters
password$
String. Optional. The password must match the user ID password. If you do not specify a password, you will be prompted for a password as required and as the software permits. If the software does not support prompting (for example, VBScript under ASP/IIS), you must supply the password or the user ID must not have one.
Usage
This method can be used on a computer with a Notes Client or Domino Server.
This method assumes that you trust the local Domino or Notes installation.
Access to the Domino Objects is as a client if the user ID is not specified as a server in the local Domino Directory or Notes Directory. Otherwise, access is as a server. As a client, you can access any server that accepts your user ID. As a server, you can access only the local server.

Leslie
 
If Notes is already open, do you need to initialize and pass the username and password to send an email through access?

Thanks!!
LJA
 
no, if notes is already open, you just need to send the message.

HTH

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top