Link to home
Start Free TrialLog in
Avatar of Petrobras
PetrobrasFlag for United States of America

asked on

Send an E-mail using Lotus Notes

Experts,
I am wanting to press a button to email the Me!frmDeals!Contact for a form I am on.  The text box is a drop down that has tblEx-ImContacts as a row source and I can select whoever the contact is for this particular deal.  When I click the drop down then I see name, phone, email.  When I click on the button "send email" I only want Lotus Notes to start with that person's email in the "send to" field.  I have seen code on here but not quite what I was lookiing for.  I am not a programmer so please use easy to understand language.

thank you
Avatar of BrentTemple
BrentTemple

I just did something like that the other day.

in the subroutine for the email buttons click event, put something like this:

    Dim sTo, sSubject, sMessage As String
    sSubject = "Yada Yada Yada"
    sMessage = "Blah Blah Blah"
    sTo = me!frmDeals!Contact

    DoCmd.SendObject acSendNoObject, , , sTo, , , sSubject, sMessage, True

HTH
-Brent
PS:  The last word on this line "DoCmd.SendObject acSendNoObject, , , sTo, , , sSubject, sMessage, True" = True, which means that the email will be created in Notes, but won't be sent.  Change it to false if you want the email to go without your intervention.
Avatar of Petrobras

ASKER

Brent,

I do not have LN on this computer now only Outlook.  
I tested and Outlook does come up with Subject and Body...it was cool.
However, I did not want it hard coded so I modified with
sSubject = InputBox$("Enter the Subject of E-mail:")
sMessage = InputBox$("Enter the Body of E-mail:")

When I get to my computer that has LN then I do not see what is in the code that would call Lotus Notes instead of Outlook?  Also, in the email address I have the Contact ID (it says "10") of the Email...not the actual email address.  I am not sure of the proper code to get the email address to appear instead of the ID of the contact.

My code follows:
Private Sub Send_Email_Click()

    Dim sTo, sSubject, sMessage As String
    sSubject = InputBox$("Enter the Subject of E-mail:")
    sMessage = InputBox$("Enter the Body of E-mail:")
    sTo = Me![ExIm]

    DoCmd.SendObject acSendNoObject, , , sTo, , , sSubject, sMessage, True

End Sub

thank you
Q1)  When you get to a computer that has LN instead of Outlook, then the same code should work, provided that Notes is set as the default Email program on your PC.   I've used the same code on two different PC's one with Notes, one with Outlook.
Q2) If your field doesn't have the email address for the Contact you've picked, You've got to have another table that links the two together, and use a lookup.   Like this:

sTo = DLookup("[EmailFieldName]", "TableName", "[ContactFieldName] = '" & me!frmDeals!Contact & "'")

(change the assumed fieldnames as necessary)

-Brent

Brent,

I will try it in the morning to see if Lotus Notes comes up.  
maybe you know why I get this error:
Property let procedure not defined and property get procedure did not return and object

sTo = DLookup("[Email]", "tblEx-ImContacts", "[Contact] = '" & Me!ExIm!Contact & "'")

Thank you
What is Me!ExIm!Contact?  is that on your form?   I think you might be able to use Me.Contact if Contact is the field on the form you want to use.

And actually, as I re-read your first post, I missed the obvious.   You did say you had the field email displaying, we can cut the whole DLookup out...   Just use this:
sTo = me.[email]

I feel a little oblivious!  :-)
-Brent
Brent,

This form is named frmDeals.  I have a combo box with a row source of
SELECT [tblEx-ImContacts].ExIM_ID, [tblEx-ImContacts].Contact, [tblEx-ImContacts].Phone, [tblEx-ImContacts].Email FROM [tblEx-ImContacts] ORDER BY [tblEx-ImContacts].Contact;

I cant figure out how the line contacts email to appear in the line sTo =

thank you



Oh, well if the email just shows up in the combobox, then we will have to go back to a DLookup solution.  I don't know of a good way to extract the email from the unbound part of the combobox.

Try this:
sTo = DLookup("[Email]", "tblEx-ImContacts", "[Contact] = '" & Me.Contact & "'")

Assumes that the combobox is named "Contact".
Assumes that the bound column on the combobox is #2, (Contact).
If the bound column in the combobox is actually #1, ExIM_ID, then try this:
sTo = DLookup("[Email]", "tblEx-ImContacts", "[ExIM_ID] = '" & Me.Contact & "'")

-Brent
There are also some good examples here that are very notes-specific and a lot more code.  

http://www.forumtopics.com/busobj/viewtopic.php?t=26805
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

I've used something quite similar, but my signature ends up at the top, and it doesn't seem to leave mail in my Sent Mail folder.   You said that you aren't a programmer, so you probably want to stick with the other solution.

The difference is that with this approach you can attach any file from your computer.  The doCmd.SendObject only allows you to send attachments from the current database.  
Hi Brent,

I am getting a data type mismatch in the line:
sTo = DLookup("[Email]", "tblEx-ImContacts", "[ExIM_ID] = '" & Me.ExIM_ID & "'")

I think the problem might be in the "Me.ExIM_ID" part.  
I tried to replace with email, contact but I got a compile error.

The bound column (primary key) is ExIM_ID and it is column #1.  
IN the row source of the combo box (named "ExIm") I have coulumns named and in this order:
ExIM_ID
Contact
Phone
Email

Thank you for your help...
ASKER CERTIFIED SOLUTION
Avatar of BrentTemple
BrentTemple

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow, it worked!  It saves in the sent folder of LN as well.  Thank you for staying with me on this one.  I wish I could give you more than 500.

thank you
Tony