Email recipients list

G

Guest

I already have my lotus Notes email working to send my report, but I need to
send to recipients based on a query, "ECN Participants." The trouble(s) I am
having is how to take my query, which has multiple columns, and convert them
into one column. I have a recipients = "" line in my module which works if I
manually type in the names in the module, but I need to be able to send to
those who participated in the initial process. Bottom line: I need to
replace the "" with code to send the email to those selected by the query. I
need a miracle here, please!!!!!!
 
G

Guest

You will need to use a SQL statement in your codes and a while loop. I do
not know anything about your table structure so I will just give a general
example I use. If you are not real sure about writing a SQL statement you
can get a general idea by creating a query in design view and then change the
view to SQL view. You will need to work with it a little but it gives you a
start. This is how I have done it.

Dim recipients As String
Dim sqlst As String
Dim con, rs As Object

sqlst = "Select * From [Total_Passwords] Where [to] = true and ([Obsolete] =
0)"

Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.recordset")

rs.Open sqlst, con, 1
recipients = rs!
rs.MoveNext
While (Not (rs.EOF))
recipients = recipients & "; " & rs![email]
rs.MoveNext
Wend
rs.Close
 
T

Tom Wickerath

Hi Bryan,

If I understand you correctly, you need to create a delimited string of e-mail addresses,
something like this:

(e-mail address removed); (e-mail address removed); (e-mail address removed); etc.

Is this correct?

The part that is troubling me a little is your statement: "The trouble(s) I am having is how to
take my query, which has multiple columns, and convert them into one column."

If you are trying to concatenate e-mail addresses, I certainly hope your query is returning
multiple records (not columns), and that you need to convert them into one record. You need to
take another look at your database design if you are storing e-mail addresses in different fields
(columns) in the table.

Anyway, Allen Browne has the tip that I think you are looking for:

http://groups-beta.google.com/group...4be3100?tvc=1&scrollSave=&&d#f8ef46d604be3100


Tom
______________________________


I already have my lotus Notes email working to send my report, but I need to
send to recipients based on a query, "ECN Participants." The trouble(s) I am
having is how to take my query, which has multiple columns, and convert them
into one column. I have a recipients = "" line in my module which works if I
manually type in the names in the module, but I need to be able to send to
those who participated in the initial process. Bottom line: I need to
replace the "" with code to send the email to those selected by the query. I
need a miracle here, please!!!!!!
 
G

Guest

Hey Tom,

I have 7 separate fields to pick up the names of the "participants." Each
of these is "signing" their form. The query I wrote picks up these names.
Different people could sign these depending upon the ECN, so I am picking up
only those names relating to that particular record. So now my query has 7
separate fields, i.e. columns. I have a report based on that record that I
am sending to initiate implementation. It has been an interesting challenge
in that my lotus Notes laughed at my attempt to use SendObject and so I had a
tough job of creating the module. I am going to try and incorporate the the
ideas already generated. Thanks!
 
T

Tom Wickerath

Hi Bryan,
I have 7 separate fields to pick up the names of the "participants."
This is not a proper database design. You have a one-to-many (1:M) relationship between ECN
(Engineering Change Notice?
http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=ECN&Find=Find) and participants. A
table should represent a single subject. Your table seems to describe two different subjects:
ECN's and participants. The problem with such a design is that if you need to add an 8th
participant (or reduce the number of participants to 5 or 6, for example), you will need to add
or remove fields in your table, and make the necessary adjustments to your queries, forms, Data
Access Pages (if you use these) and reports. The general rule of thumb is "Adding fields is
expensive; adding records is cheap". Your database design should be such that you can add or
remove similar data (for example, participants and their e-mail addresses) without having to make
design changes. You can likely use a union query with your current design to return the e-mail
addresses as separate records. The results of the union query would be fed into the BulkE-mail
function that I showed earlier. However, that's a lot of extra work to have to go through to
accommodate an improper database design.

Storing ECN attributes in one table and Participant attributes in another table will allow you to
take advantage of the relational characteristics of your data. Are you familiar with creating
relationships between tables, such as 1:M and M:N (many-to-many, which is simply two 1:M with a
linking table)?

It has been an interesting challenge in that my lotus Notes
laughed at my attempt to use SendObject

I'm never used Lotus Notes. KB article 231797 (http://support.microsoft.com/?id=231797) includes
the following statement:

"When you use the SendObject method within Microsoft Access, you must have a messaging
application (for example, Microsoft Outlook), that supports the Microsoft Mail Applications
Programming Interface or MAPI."

A quick search of the IBM web site seems to indicate that Notes can be set up to support MAPI:
http://www.developer.ibm.com/tech/faq/individual?oid=2:22171

"This includes using Microsoft Outlook or Exchange, or IBM Lotus Notes using MAPI instead of the
VIM mail interface. Look at the documentation for your mail service to set up the MAPI
interface."

Your initial message seemed to indicate that you had SendObject working correctly with Lotus
Notes, when you manually type in the names in the module. So, it doesn't appear that the problem
is with Notes. What happens if you manually type in a semicolon delimited string of e-mail
addresses, such as "(e-mail address removed); (e-mail address removed); (e-mail address removed)"? I
recommend using a semicolon to delimit your list of names versus a comma.

Other reasons for SendObject failing in Access include the following:

http://support.microsoft.com/?id=260819

Are you trying to enter a delimited list of names, instead of e-mail addresses? If so, do the
names include commas, as in Lastname, Firstname? This KB article might help you out:
http://support.microsoft.com/?id=210309


Good Luck!

Tom
____________________________________


Hey Tom,

I have 7 separate fields to pick up the names of the "participants." Each
of these is "signing" their form. The query I wrote picks up these names.
Different people could sign these depending upon the ECN, so I am picking up
only those names relating to that particular record. So now my query has 7
separate fields, i.e. columns. I have a report based on that record that I
am sending to initiate implementation. It has been an interesting challenge
in that my lotus Notes laughed at my attempt to use SendObject and so I had a
tough job of creating the module. I am going to try and incorporate the the
ideas already generated. Thanks!

____________________________________


Hi Bryan,

If I understand you correctly, you need to create a delimited string of e-mail addresses,
something like this:

(e-mail address removed); (e-mail address removed); (e-mail address removed); etc.

Is this correct?

The part that is troubling me a little is your statement: "The trouble(s) I am having is how to
take my query, which has multiple columns, and convert them into one column."

If you are trying to concatenate e-mail addresses, I certainly hope your query is returning
multiple records (not columns), and that you need to convert them into one record. You need to
take another look at your database design if you are storing e-mail addresses in different fields
(columns) in the table.

Anyway, Allen Browne has the tip that I think you are looking for:

http://groups-beta.google.com/group...4be3100?tvc=1&scrollSave=&&d#f8ef46d604be3100


Tom

____________________________________


I already have my lotus Notes email working to send my report, but I need to
send to recipients based on a query, "ECN Participants." The trouble(s) I am
having is how to take my query, which has multiple columns, and convert them
into one column. I have a recipients = "" line in my module which works if I
manually type in the names in the module, but I need to be able to send to
those who participated in the initial process. Bottom line: I need to
replace the "" with code to send the email to those selected by the query. I
need a miracle here, please!!!!!!
 
G

Guest

Hey Tom,
I am not using SendObject at all. I've included my code so you can see
where I am:


Private Sub sendemail_Click()
Dim Recipients As String, strBody As String
Dim SendTo As String, attachpath As String
Dim Session As Object, db As Object, doc As Object, rtitem As Object, tmp As
Object

'On Error GoTo Err_SendEMail

'Sets up Notes Session and opens the mail database
Me.Refresh
Set Session = CreateObject("Notes.Notessession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
Recipients = "Bryan Daniels"

'Creates the mail document, sets the body, sendto, and Subject fields
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, "Backlog Quality", acFormatRTF, "s:\ECR
Temp\Backlog Quality.rtf", False
strBody = "Please implement the enclosed ECN"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)

'Here is the way to attach a file
Set tmp = rtitem.EmbedObject(1454, "", "s:\ECR Temp\Backlog Quality.rtf")
Call doc.replaceitemvalue("SendTo", Recipients)

Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)

MsgBox ("Message has been sent.")
Set Session = Nothing

Exit_SendEMail:
Set Session = Nothing
Set db = Nothing
Exit Sub

Err_SendEMail:
MsgBox Err.Description
Resume Exit_SendEMail

End Sub

You got the ECN right!!
I am a little confused by the improper database design thing. Everything
within each record varies, including the names of the participants. Lotus
Notes allows me to simply use the names and not have to input email
addresses, i.e., FirstName LastName. That was my original logic for not
having to create a separate table. There is no list I'm drawing from, just
using form entries. I've also included my query SQL so you can see how I've
ended up with columns. Am I making any sense at all??!! I really appreciate
your input and improving my understanding!
Thanks again!

SELECT Table1.Originator, Table1.[Engineer Name], Table1.[Manufacturing and
Test Name], Table1.[Master Scheduler Name], Table1.[Procurement Name],
Table1.[P&L Managers Name], Table1.[Quality Name]
FROM Table1
WHERE (((Table1.[ECR Number])=[screen].[Activeform].[ECR Number]));
 
T

Tom Wickerath

Hi Bryan,

I need to head to work now, so it will be at least 10 hours or so before I can reply back. In the
meantime, I suggest reading the following articles:

http://www.datatexcg.com/Downloads/DatabaseDesignTips1997.pdf
http://www.eade.com/AccessSIG/downloads.htm
(See the last download titled "Understanding Normalization")

http://support.microsoft.com/?id=234208
http://support.microsoft.com/?id=289533

Thanks for including the code for Lotus Notes. That may come in handy some day for me.

Tom
______________________________________

Hey Tom,
I am not using SendObject at all. I've included my code so you can see
where I am:


Private Sub sendemail_Click()
Dim Recipients As String, strBody As String
Dim SendTo As String, attachpath As String
Dim Session As Object, db As Object, doc As Object, rtitem As Object, tmp As
Object

'On Error GoTo Err_SendEMail

'Sets up Notes Session and opens the mail database
Me.Refresh
Set Session = CreateObject("Notes.Notessession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
Recipients = "Bryan Daniels"

'Creates the mail document, sets the body, sendto, and Subject fields
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, "Backlog Quality", acFormatRTF, "s:\ECR
Temp\Backlog Quality.rtf", False
strBody = "Please implement the enclosed ECN"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)

'Here is the way to attach a file
Set tmp = rtitem.EmbedObject(1454, "", "s:\ECR Temp\Backlog Quality.rtf")
Call doc.replaceitemvalue("SendTo", Recipients)

Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)

MsgBox ("Message has been sent.")
Set Session = Nothing

Exit_SendEMail:
Set Session = Nothing
Set db = Nothing
Exit Sub

Err_SendEMail:
MsgBox Err.Description
Resume Exit_SendEMail

End Sub

You got the ECN right!!
I am a little confused by the improper database design thing. Everything
within each record varies, including the names of the participants. Lotus
Notes allows me to simply use the names and not have to input email
addresses, i.e., FirstName LastName. That was my original logic for not
having to create a separate table. There is no list I'm drawing from, just
using form entries. I've also included my query SQL so you can see how I've
ended up with columns. Am I making any sense at all??!! I really appreciate
your input and improving my understanding!
Thanks again!

SELECT Table1.Originator, Table1.[Engineer Name], Table1.[Manufacturing and
Test Name], Table1.[Master Scheduler Name], Table1.[Procurement Name],
Table1.[P&L Managers Name], Table1.[Quality Name]
FROM Table1
WHERE (((Table1.[ECR Number])=[screen].[Activeform].[ECR Number]));
 
T

Tom Wickerath

Hi Bryan,

Okay, I'm going to take a guess at the structure of your Table1 table:

ECR Number (Text)
Originator (Text)
Engineer Name (Text)
Manufacturing and Test Name (Text)
Master Scheduler Name (Text)
Procurement Name (Text)
P&L Managers Name (Text)

You need a union query to bring these names into one column. To create a Union query, start with
a brand new query, but do not select any tables. In query design view, click on View > SQL View.
You should see the word SELECT highlighted. Replace this word with the following SQL statement:

SELECT Originator AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));


I recommend saving this query as: quniAllRecipients instead of "ECN Participants". The quni
prefix is a Hungarian naming convention that identifies the object as a q=query + uni=union, or
union query.

I am using a criteria that includes:
[Forms]![FormName]![FieldName]

I've chosen frmECN as the name of the form, which gives me:
[Forms]![frmECN]![ECR Number]

as the criteria on the ECR Number field, instead of the form that you indicated:
[screen].[Activeform].[ECR Number]

When you run the union query, with the frmECN form open to a current record, you should see each
person's name as a separate record. This rather ugly looking union query is not necessary when
one has a proper database design.

Paste the following code into the code module for the frmECN form. Please note the following
points:

1.) I added my style of an error handler. This includes using
On Error Resume Next in the ExitProc section, just prior to closing objects
and setting them equal to nothing.

2.) You have a Me.Refresh that I'm not sure is required.

3.) You need to include a reference to the "Microsoft DAO 3.6 Object Library" if you don't
already have this reference set. When viewing code, click on Tools > References and scroll down
the list until you find this library. Place a check to select it.

4.) I had to modify the original BulkEmail function, in order to prevent run-time error 3061 with
a parameter query.
See: http://support.microsoft.com/?id=210244 for more details.

5.) I eliminated two lines of code from the original BulkEmail function:
Dim strSQL As String and
strSQL = "SELECT Email FROM MyTable WHERE Email Is Not N­ull;"

since I was using a saved querydef instead.

6.) I'm not positive, but I think there are additional objects that you should be closing and/or
setting equal to nothing in the ExitProc section of Private Sub sendemail_Click(). This includes
Session, db, doc rtitem, and tmp.

Finally, I wasn't able to test your code thoroughly, since I don't have Lotus Notes available.
However, I did verify that the Recipients string was returning a semi-colon delimited list of
names.

Good Luck!
Please let me know how it goes for you.

Tom

PS. Work on improving that database design, so that you can eliminate the ugly union query.


'*******************Begin Code***************************

Option Compare Database
Option Explicit

Private Sub sendemail_Click()
On Error GoTo ProcError

Dim Recipients As String, strBody As String
Dim SendTo As String, attachpath As String
Dim Session As Object, db As Object, doc As Object, rtitem As Object, tmp As Object

'Sets up Notes Session and opens the mail database
Me.Refresh '<---I'm not sure this is necessary
'Set Session = CreateObject("Notes.Notessession")
'Set db = Session.GetDatabase("", "")
'Call db.OPENMAIL
Recipients = BulkEmail()
Exit Sub

'Creates the mail document, sets the body, sendto, and Subject fields
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, "Backlog Quality", acFormatRTF, "s:\ECR Temp\Backlog Quality.rtf",
False
strBody = "Please implement the enclosed ECN"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)

'Here is the way to attach a file
Set tmp = rtitem.EmbedObject(1454, "", "s:\ECR Temp\Backlog Quality.rtf")
Call doc.replaceitemvalue("SendTo", Recipients)

Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)

MsgBox ("Message has been sent.")
Set Session = Nothing


ExitProc:
'Cleanup
On Error Resume Next '<-----Add this line
Set Session = Nothing
Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure sendemail_Click..."
Resume ExitProc

End Sub

Function BulkEmail() As String
On Error GoTo ProcError

'Purpose: Return a concatenated string from individual records in a recordset

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strOut As String
Dim lngLen As Long
Const conSEP = ";"

Set db = CurrentDb()
Set qdf = db.QueryDefs("quniAllRecipients")

qdf![[Forms]![frmECN]![ECR Number]] = [Forms]![frmECN]![ECR Number]

Set rs = qdf.OpenRecordset(dbOpenSnapshot)

With rs
Do While Not .EOF
strOut = strOut & !Recipient & conSEP
.MoveNext
Loop
End With

lngLen = Len(strOut) - Len(conSEP)
If lngLen > 0 Then
BulkEmail = Left$(strOut, lngLen)
End If

Debug.Print BulkEmail

ExitProc:
'Cleanup
On Error Resume Next
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Exit Function

ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure BulkEmail..."
Resume ExitProc

End Function

'*********************End Code**********************

______________________________________


Hi Bryan,

I need to head to work now, so it will be at least 10 hours or so before I can reply back. In the
meantime, I suggest reading the following articles:

http://www.datatexcg.com/Downloads/DatabaseDesignTips1997.pdf
http://www.eade.com/AccessSIG/downloads.htm
(See the last download titled "Understanding Normalization")

http://support.microsoft.com/?id=234208
http://support.microsoft.com/?id=289533

Thanks for including the code for Lotus Notes. That may come in handy some day for me.

Tom
______________________________________

Hey Tom,
I am not using SendObject at all. I've included my code so you can see
where I am:


Private Sub sendemail_Click()
Dim Recipients As String, strBody As String
Dim SendTo As String, attachpath As String
Dim Session As Object, db As Object, doc As Object, rtitem As Object, tmp As
Object

'On Error GoTo Err_SendEMail

'Sets up Notes Session and opens the mail database
Me.Refresh
Set Session = CreateObject("Notes.Notessession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
Recipients = "Bryan Daniels"

'Creates the mail document, sets the body, sendto, and Subject fields
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, "Backlog Quality", acFormatRTF, "s:\ECR
Temp\Backlog Quality.rtf", False
strBody = "Please implement the enclosed ECN"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)

'Here is the way to attach a file
Set tmp = rtitem.EmbedObject(1454, "", "s:\ECR Temp\Backlog Quality.rtf")
Call doc.replaceitemvalue("SendTo", Recipients)

Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)

MsgBox ("Message has been sent.")
Set Session = Nothing

Exit_SendEMail:
Set Session = Nothing
Set db = Nothing
Exit Sub

Err_SendEMail:
MsgBox Err.Description
Resume Exit_SendEMail

End Sub

You got the ECN right!!
I am a little confused by the improper database design thing. Everything
within each record varies, including the names of the participants. Lotus
Notes allows me to simply use the names and not have to input email
addresses, i.e., FirstName LastName. That was my original logic for not
having to create a separate table. There is no list I'm drawing from, just
using form entries. I've also included my query SQL so you can see how I've
ended up with columns. Am I making any sense at all??!! I really appreciate
your input and improving my understanding!
Thanks again!

SELECT Table1.Originator, Table1.[Engineer Name], Table1.[Manufacturing and
Test Name], Table1.[Master Scheduler Name], Table1.[Procurement Name],
Table1.[P&L Managers Name], Table1.[Quality Name]
FROM Table1
WHERE (((Table1.[ECR Number])=[screen].[Activeform].[ECR Number]));
 
G

Guest

Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!

Tom Wickerath said:
Hi Bryan,

Okay, I'm going to take a guess at the structure of your Table1 table:

ECR Number (Text)
Originator (Text)
Engineer Name (Text)
Manufacturing and Test Name (Text)
Master Scheduler Name (Text)
Procurement Name (Text)
P&L Managers Name (Text)

You need a union query to bring these names into one column. To create a Union query, start with
a brand new query, but do not select any tables. In query design view, click on View > SQL View.
You should see the word SELECT highlighted. Replace this word with the following SQL statement:

SELECT Originator AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION
SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));


I recommend saving this query as: quniAllRecipients instead of "ECN Participants". The quni
prefix is a Hungarian naming convention that identifies the object as a q=query + uni=union, or
union query.

I am using a criteria that includes:
[Forms]![FormName]![FieldName]

I've chosen frmECN as the name of the form, which gives me:
[Forms]![frmECN]![ECR Number]

as the criteria on the ECR Number field, instead of the form that you indicated:
[screen].[Activeform].[ECR Number]

When you run the union query, with the frmECN form open to a current record, you should see each
person's name as a separate record. This rather ugly looking union query is not necessary when
one has a proper database design.

Paste the following code into the code module for the frmECN form. Please note the following
points:

1.) I added my style of an error handler. This includes using
On Error Resume Next in the ExitProc section, just prior to closing objects
and setting them equal to nothing.

2.) You have a Me.Refresh that I'm not sure is required.

3.) You need to include a reference to the "Microsoft DAO 3.6 Object Library" if you don't
already have this reference set. When viewing code, click on Tools > References and scroll down
the list until you find this library. Place a check to select it.

4.) I had to modify the original BulkEmail function, in order to prevent run-time error 3061 with
a parameter query.
See: http://support.microsoft.com/?id=210244 for more details.

5.) I eliminated two lines of code from the original BulkEmail function:
Dim strSQL As String and
strSQL = "SELECT Email FROM MyTable WHERE Email Is Not N­ull;"

since I was using a saved querydef instead.

6.) I'm not positive, but I think there are additional objects that you should be closing and/or
setting equal to nothing in the ExitProc section of Private Sub sendemail_Click(). This includes
Session, db, doc rtitem, and tmp.

Finally, I wasn't able to test your code thoroughly, since I don't have Lotus Notes available.
However, I did verify that the Recipients string was returning a semi-colon delimited list of
names.

Good Luck!
Please let me know how it goes for you.

Tom

PS. Work on improving that database design, so that you can eliminate the ugly union query.


'*******************Begin Code***************************

Option Compare Database
Option Explicit

Private Sub sendemail_Click()
On Error GoTo ProcError

Dim Recipients As String, strBody As String
Dim SendTo As String, attachpath As String
Dim Session As Object, db As Object, doc As Object, rtitem As Object, tmp As Object

'Sets up Notes Session and opens the mail database
Me.Refresh '<---I'm not sure this is necessary
'Set Session = CreateObject("Notes.Notessession")
'Set db = Session.GetDatabase("", "")
'Call db.OPENMAIL
Recipients = BulkEmail()
Exit Sub

'Creates the mail document, sets the body, sendto, and Subject fields
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, "Backlog Quality", acFormatRTF, "s:\ECR Temp\Backlog Quality.rtf",
False
strBody = "Please implement the enclosed ECN"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)

'Here is the way to attach a file
Set tmp = rtitem.EmbedObject(1454, "", "s:\ECR Temp\Backlog Quality.rtf")
Call doc.replaceitemvalue("SendTo", Recipients)

Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)

MsgBox ("Message has been sent.")
Set Session = Nothing


ExitProc:
'Cleanup
On Error Resume Next '<-----Add this line
Set Session = Nothing
Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure sendemail_Click..."
Resume ExitProc

End Sub

Function BulkEmail() As String
On Error GoTo ProcError

'Purpose: Return a concatenated string from individual records in a recordset

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strOut As String
Dim lngLen As Long
Const conSEP = ";"

Set db = CurrentDb()
Set qdf = db.QueryDefs("quniAllRecipients")

qdf![[Forms]![frmECN]![ECR Number]] = [Forms]![frmECN]![ECR Number]

Set rs = qdf.OpenRecordset(dbOpenSnapshot)

With rs
Do While Not .EOF
strOut = strOut & !Recipient & conSEP
.MoveNext
Loop
End With

lngLen = Len(strOut) - Len(conSEP)
If lngLen > 0 Then
BulkEmail = Left$(strOut, lngLen)
End If

Debug.Print BulkEmail

ExitProc:
'Cleanup
On Error Resume Next
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Exit Function

ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure BulkEmail..."
Resume ExitProc

End Function

'*********************End Code**********************

______________________________________


Hi Bryan,

I need to head to work now, so it will be at least 10 hours or so before I can reply back. In the
meantime, I suggest reading the following articles:

http://www.datatexcg.com/Downloads/DatabaseDesignTips1997.pdf
http://www.eade.com/AccessSIG/downloads.htm
(See the last download titled "Understanding Normalization")

http://support.microsoft.com/?id=234208
http://support.microsoft.com/?id=289533

Thanks for including the code for Lotus Notes. That may come in handy some day for me.

Tom
______________________________________

Hey Tom,
I am not using SendObject at all. I've included my code so you can see
where I am:


Private Sub sendemail_Click()
Dim Recipients As String, strBody As String
Dim SendTo As String, attachpath As String
Dim Session As Object, db As Object, doc As Object, rtitem As Object, tmp As
Object

'On Error GoTo Err_SendEMail

'Sets up Notes Session and opens the mail database
Me.Refresh
Set Session = CreateObject("Notes.Notessession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
Recipients = "Bryan Daniels"

'Creates the mail document, sets the body, sendto, and Subject fields
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, "Backlog Quality", acFormatRTF, "s:\ECR
Temp\Backlog Quality.rtf", False
strBody = "Please implement the enclosed ECN"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)

'Here is the way to attach a file
Set tmp = rtitem.EmbedObject(1454, "", "s:\ECR Temp\Backlog Quality.rtf")
Call doc.replaceitemvalue("SendTo", Recipients)

Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)

MsgBox ("Message has been sent.")
Set Session = Nothing

Exit_SendEMail:
Set Session = Nothing
Set db = Nothing
Exit Sub

Err_SendEMail:
MsgBox Err.Description
Resume Exit_SendEMail

End Sub

You got the ECN right!!
I am a little confused by the improper database design thing. Everything
within each record varies, including the names of the participants. Lotus
Notes allows me to simply use the names and not have to input email
addresses, i.e., FirstName LastName. That was my original logic for not
having to create a separate table. There is no list I'm drawing from, just
using form entries. I've also included my query SQL so you can see how I've
ended up with columns. Am I making any sense at all??!! I really appreciate
your input and improving my understanding!
Thanks again!

SELECT Table1.Originator, Table1.[Engineer Name], Table1.[Manufacturing and
Test Name], Table1.[Master Scheduler Name], Table1.[Procurement Name],
Table1.[P&L Managers Name], Table1.[Quality Name]
FROM Table1
WHERE (((Table1.[ECR Number])=[screen].[Activeform].[ECR Number]));



Tom Wickerath said:
Hi Bryan,

This is not a proper database design. You have a one-to-many (1:M) relationship between ECN
(Engineering Change Notice?
http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=ECN&Find=Find) and participants. A
table should represent a single subject. Your table seems to describe two different subjects:
ECN's and participants. The problem with such a design is that if you need to add an 8th
participant (or reduce the number of participants to 5 or 6, for example), you will need to add
or remove fields in your table, and make the necessary adjustments to your queries, forms, Data
Access Pages (if you use these) and reports. The general rule of thumb is "Adding fields is
expensive; adding records is cheap". Your database design should be such that you can add or
remove similar data (for example, participants and their e-mail addresses) without having to make
design changes. You can likely use a union query with your current design to return the e-mail
addresses as separate records. The results of the union query would be fed into the BulkE-mail
function that I showed earlier. However, that's a lot of extra work to have to go through to
accommodate an improper database design.

Storing ECN attributes in one table and Participant attributes in another table will allow you to
take advantage of the relational characteristics of your data. Are you familiar with creating
relationships between tables, such as 1:M and M:N (many-to-many, which is simply two 1:M with a
linking table)?



I'm never used Lotus Notes. KB article 231797 (http://support.microsoft.com/?id=231797) includes
the following statement:

"When you use the SendObject method within Microsoft Access, you must have a messaging
application (for example, Microsoft Outlook), that supports the Microsoft Mail Applications
Programming Interface or MAPI."

A quick search of the IBM web site seems to indicate that Notes can be set up to support MAPI:
http://www.developer.ibm.com/tech/faq/individual?oid=2:22171

"This includes using Microsoft Outlook or Exchange, or IBM Lotus Notes using MAPI instead of the
VIM mail interface. Look at the documentation for your mail service to set up the MAPI
interface."

Your initial message seemed to indicate that you had SendObject working correctly with Lotus
Notes, when you manually type in the names in the module. So, it doesn't appear that the problem
is with Notes. What happens if you manually type in a semicolon delimited string of e-mail
addresses, such as "(e-mail address removed); (e-mail address removed); (e-mail address removed)"? I
recommend using a semicolon to delimit your list of names versus a comma.

Other reasons for SendObject failing in Access include the following:

http://support.microsoft.com/?id=260819

Are you trying to enter a delimited list of names, instead of e-mail addresses? If so, do the
names include commas, as in Lastname, Firstname? This KB article might help you out:
http://support.microsoft.com/?id=210309


Good Luck!

Tom
____________________________________


Hey Tom,

I have 7 separate fields to pick up the names of the "participants." Each
of these is "signing" their form. The query I wrote picks up these names.
Different people could sign these depending upon the ECN, so I am picking up
only those names relating to that particular record. So now my query has 7
separate fields, i.e. columns. I have a report based on that record that I
am sending to initiate implementation. It has been an interesting challenge
in that my lotus Notes laughed at my attempt to use SendObject and so I had a
tough job of creating the module. I am going to try and incorporate the the
ideas already generated. Thanks!

____________________________________


Hi Bryan,

If I understand you correctly, you need to create a delimited string of e-mail addresses,
something like this:

(e-mail address removed); (e-mail address removed); (e-mail address removed); etc.

Is this correct?

The part that is troubling me a little is your statement: "The trouble(s) I am having is how to
take my query, which has multiple columns, and convert them into one column."

If you are trying to concatenate e-mail addresses, I certainly hope your query is returning
multiple records (not columns), and that you need to convert them into one record. You need to
take another look at your database design if you are storing e-mail addresses in different fields
(columns) in the table.

Anyway, Allen Browne has the tip that I think you are looking for:

http://groups-beta.google.com/group...4be3100?tvc=1&scrollSave=&&d#f8ef46d604be3100


Tom

____________________________________


I already have my lotus Notes email working to send my report, but I need to
send to recipients based on a query, "ECN Participants." The trouble(s) I am
having is how to take my query, which has multiple columns, and convert them
into one column. I have a recipients = "" line in my module which works if I
manually type in the names in the module, but I need to be able to send to
those who participated in the initial process. Bottom line: I need to
replace the "" with code to send the email to those selected by the query. I
need a miracle here, please!!!!!!
 
T

Tom Wickerath

Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without having to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
G

Guest

That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan

Tom Wickerath said:
Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without having to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
T

Tom Wickerath

Hi Bryan,

I'm happy to hear that you got it working!

Thanks for the nice compliment. Good luck in your studies and application of database
normalization techniques.


Tom
____________________________________


That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan
____________________________________

Tom Wickerath said:
Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without having to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
G

Guest

Tom,

Sorry to bother you again, but it is not working as well as I had hoped. I
looked at your Debug screen and it looked great. I inserted only my own name
in the form and it worked great. I did not try to insert several names until
late yesterday when I had the report finished. I got back an error message
saying, "Unable to send mail, no match found in Name & Address book(s)." I
rechecked notes by manually inserting the list exactly as shown in the debug
screen and that works. This morning I got the idea to change your debug to
Debug.Print Recipients in the sendemail module and guess what? If I use one
name, it shows that name. If I use multiple names, it comes up blank. So
the bulkEmail module works, but the code in the sendEmail doesn't. Any
ideas??

Tom Wickerath said:
Hi Bryan,

I'm happy to hear that you got it working!

Thanks for the nice compliment. Good luck in your studies and application of database
normalization techniques.


Tom
____________________________________


That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan
____________________________________

Tom Wickerath said:
Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without having to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
T

Tom Wickerath

Hi Bryan,
If I use one name, it shows that name. If I use multiple names, it comes up blank.
"It" refers to Lotus Notes, correct? If so, I believe you are dealing with a Lotus Notes issue,
although I'm not positive....

I would experiment with some concatenated forms of known good names when addressing messages in
Lotus Notes. Perhaps you can find some documentation in Lotus Notes that covers this information.
For example, if you add my name and e-mail address, and your name and e-mail address, to the
Lotus Notes address book, which form of a concatenated string works (if any):

1.) Bryan; Tom Wickerath (semi-colon only delimited)
2.) Bryan, Tom Wickerath (comma only delimited)
3.) 'Bryan'; 'Tom Wickerath' (semi-colon delimited with single quote around each value)
4.) 'Bryan', 'Tom Wickerath' (comma delimited with single quote around each value)
5.) "Bryan"; "Tom Wickerath" (semi-colon delimited with double quotes around each value)
6.) "Bryan", "Tom Wickerath" (comma delimited with double quotes around each value)

What about:
7.) Bryan; Wickerath Tom (semi-colon only delimited with last name first)
8.) Bryan; Wickerath, Tom (semi-colon only delimited with last name first + comma
separating last & first names)

Since I don't know your last name, I cannot include it in the examples above.

Do you have Outlook or Outlook Express available on a test machine? If so, try setting one of
these e-mail clients as the default MAPI client. Enter some known good names into the address
book and then repeat the experiment. If it works then you've pretty much verified that it is a
Lotus Notes issue. Can you get any support from IBM on Lotus Notes issues, or is there a
newsgroup available for this software that you can post a question to? It sounds like it is
having an issue resolving multiple names. When controlled through automation, it appears to be
treating a concatenated list as one name. When the user interacts manually, it appears to resolve
the concatenated list correctly. This is the only explanation that I have for your observation
that "I
rechecked notes by manually inserting the list exactly as shown in the debug screen and that
works." Perhaps Lotus Notes needs the equivalent of this block of code shown in KB 209948 for
Outlook, when controlled via automation:

http://support.microsoft.com/?id=209948

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next


Please follow-up with anything new that you learn. Perhaps tonight I can find time to modify the
rest of your current sendEmail procedure to work with Outlook and Outlook Express, and then test
it on my end. I have to get ready for work right now.

Tom
___________________________________


Tom,

Sorry to bother you again, but it is not working as well as I had hoped. I
looked at your Debug screen and it looked great. I inserted only my own name
in the form and it worked great. I did not try to insert several names until
late yesterday when I had the report finished. I got back an error message
saying, "Unable to send mail, no match found in Name & Address book(s)." I
rechecked notes by manually inserting the list exactly as shown in the debug
screen and that works. This morning I got the idea to change your debug to
Debug.Print Recipients in the sendemail module and guess what? If I use one
name, it shows that name. If I use multiple names, it comes up blank. So
the bulkEmail module works, but the code in the sendEmail doesn't. Any
ideas??

___________________________________

Tom Wickerath said:
Hi Bryan,

I'm happy to hear that you got it working!

Thanks for the nice compliment. Good luck in your studies and application of database
normalization techniques.


Tom
____________________________________


That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan
____________________________________

Tom Wickerath said:
Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without having to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
G

Guest

Only problem is what I am seeing in the debug window should be resolved prior
to sending to notes. I may be wrong on that, though. I have already tried
to enclose them in single quotes, no good. Then I tried using the addresses
with them. That sent, but only to the first name on the list. I'll keep
experimenting!

Tom Wickerath said:
Hi Bryan,
If I use one name, it shows that name. If I use multiple names, it comes up blank.
"It" refers to Lotus Notes, correct? If so, I believe you are dealing with a Lotus Notes issue,
although I'm not positive....

I would experiment with some concatenated forms of known good names when addressing messages in
Lotus Notes. Perhaps you can find some documentation in Lotus Notes that covers this information.
For example, if you add my name and e-mail address, and your name and e-mail address, to the
Lotus Notes address book, which form of a concatenated string works (if any):

1.) Bryan; Tom Wickerath (semi-colon only delimited)
2.) Bryan, Tom Wickerath (comma only delimited)
3.) 'Bryan'; 'Tom Wickerath' (semi-colon delimited with single quote around each value)
4.) 'Bryan', 'Tom Wickerath' (comma delimited with single quote around each value)
5.) "Bryan"; "Tom Wickerath" (semi-colon delimited with double quotes around each value)
6.) "Bryan", "Tom Wickerath" (comma delimited with double quotes around each value)

What about:
7.) Bryan; Wickerath Tom (semi-colon only delimited with last name first)
8.) Bryan; Wickerath, Tom (semi-colon only delimited with last name first + comma
separating last & first names)

Since I don't know your last name, I cannot include it in the examples above.

Do you have Outlook or Outlook Express available on a test machine? If so, try setting one of
these e-mail clients as the default MAPI client. Enter some known good names into the address
book and then repeat the experiment. If it works then you've pretty much verified that it is a
Lotus Notes issue. Can you get any support from IBM on Lotus Notes issues, or is there a
newsgroup available for this software that you can post a question to? It sounds like it is
having an issue resolving multiple names. When controlled through automation, it appears to be
treating a concatenated list as one name. When the user interacts manually, it appears to resolve
the concatenated list correctly. This is the only explanation that I have for your observation
that "I
rechecked notes by manually inserting the list exactly as shown in the debug screen and that
works." Perhaps Lotus Notes needs the equivalent of this block of code shown in KB 209948 for
Outlook, when controlled via automation:

http://support.microsoft.com/?id=209948

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next


Please follow-up with anything new that you learn. Perhaps tonight I can find time to modify the
rest of your current sendEmail procedure to work with Outlook and Outlook Express, and then test
it on my end. I have to get ready for work right now.

Tom
___________________________________


Tom,

Sorry to bother you again, but it is not working as well as I had hoped. I
looked at your Debug screen and it looked great. I inserted only my own name
in the form and it worked great. I did not try to insert several names until
late yesterday when I had the report finished. I got back an error message
saying, "Unable to send mail, no match found in Name & Address book(s)." I
rechecked notes by manually inserting the list exactly as shown in the debug
screen and that works. This morning I got the idea to change your debug to
Debug.Print Recipients in the sendemail module and guess what? If I use one
name, it shows that name. If I use multiple names, it comes up blank. So
the bulkEmail module works, but the code in the sendEmail doesn't. Any
ideas??

___________________________________

Tom Wickerath said:
Hi Bryan,

I'm happy to hear that you got it working!

Thanks for the nice compliment. Good luck in your studies and application of database
normalization techniques.


Tom
____________________________________


That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan
____________________________________

Tom Wickerath said:
Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without having to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
T

Tom Wickerath

Hi Bryan,

Send me a private e-mail message with a valid return address. I'd like to take this off-line.


Tom

AOS168 AT Comcast DOT net

The second character is a letter "O" (not zero). Should be an 18 character e-mail address.

______________________________________


Only problem is what I am seeing in the debug window should be resolved prior
to sending to notes. I may be wrong on that, though. I have already tried
to enclose them in single quotes, no good. Then I tried using the addresses
with them. That sent, but only to the first name on the list. I'll keep
experimenting!

Tom Wickerath said:
Hi Bryan,
If I use one name, it shows that name. If I use multiple names, it comes up blank.
"It" refers to Lotus Notes, correct? If so, I believe you are dealing with a Lotus Notes issue,
although I'm not positive....

I would experiment with some concatenated forms of known good names when addressing messages in
Lotus Notes. Perhaps you can find some documentation in Lotus Notes that covers this information.
For example, if you add my name and e-mail address, and your name and e-mail address, to the
Lotus Notes address book, which form of a concatenated string works (if any):

1.) Bryan; Tom Wickerath (semi-colon only delimited)
2.) Bryan, Tom Wickerath (comma only delimited)
3.) 'Bryan'; 'Tom Wickerath' (semi-colon delimited with single quote around each value)
4.) 'Bryan', 'Tom Wickerath' (comma delimited with single quote around each value)
5.) "Bryan"; "Tom Wickerath" (semi-colon delimited with double quotes around each value)
6.) "Bryan", "Tom Wickerath" (comma delimited with double quotes around each value)

What about:
7.) Bryan; Wickerath Tom (semi-colon only delimited with last name first)
8.) Bryan; Wickerath, Tom (semi-colon only delimited with last name first + comma
separating last & first names)

Since I don't know your last name, I cannot include it in the examples above.

Do you have Outlook or Outlook Express available on a test machine? If so, try setting one of
these e-mail clients as the default MAPI client. Enter some known good names into the address
book and then repeat the experiment. If it works then you've pretty much verified that it is a
Lotus Notes issue. Can you get any support from IBM on Lotus Notes issues, or is there a
newsgroup available for this software that you can post a question to? It sounds like it is
having an issue resolving multiple names. When controlled through automation, it appears to be
treating a concatenated list as one name. When the user interacts manually, it appears to resolve
the concatenated list correctly. This is the only explanation that I have for your observation
that "I
rechecked notes by manually inserting the list exactly as shown in the debug screen and that
works." Perhaps Lotus Notes needs the equivalent of this block of code shown in KB 209948 for
Outlook, when controlled via automation:

http://support.microsoft.com/?id=209948

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next


Please follow-up with anything new that you learn. Perhaps tonight I can find time to modify the
rest of your current sendEmail procedure to work with Outlook and Outlook Express, and then test
it on my end. I have to get ready for work right now.

Tom
___________________________________


Tom,

Sorry to bother you again, but it is not working as well as I had hoped. I
looked at your Debug screen and it looked great. I inserted only my own name
in the form and it worked great. I did not try to insert several names until
late yesterday when I had the report finished. I got back an error message
saying, "Unable to send mail, no match found in Name & Address book(s)." I
rechecked notes by manually inserting the list exactly as shown in the debug
screen and that works. This morning I got the idea to change your debug to
Debug.Print Recipients in the sendemail module and guess what? If I use one
name, it shows that name. If I use multiple names, it comes up blank. So
the bulkEmail module works, but the code in the sendEmail doesn't. Any
ideas??

___________________________________

Tom Wickerath said:
Hi Bryan,

I'm happy to hear that you got it working!

Thanks for the nice compliment. Good luck in your studies and application of database
normalization techniques.


Tom
____________________________________


That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan
____________________________________

to
be
having
to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 
G

Guest

Bryan,

I have followed this post and thought you may be able to help me. I have a
client who needs an access application to automatically send emails through
Lotus Notes. This is a snap with outlook, but I need to give them an
estimate on doing it with Lotus and I don't even have lotus notes on my
machine and didn't know if it could be done. It looks like you are doing
this, so I thought any insights you had would be of value.

Thanks,

Kerry
 
O

olds442freestyle

need to remove doc.[resume to be able to send

Tom Wickerath said:
Hi Bryan,

Send me a private e-mail message with a valid return address. I'd like to take this off-line.


Tom

AOS168 AT Comcast DOT net

The second character is a letter "O" (not zero). Should be an 18 character e-mail address.

______________________________________


Only problem is what I am seeing in the debug window should be resolved prior
to sending to notes. I may be wrong on that, though. I have already tried
to enclose them in single quotes, no good. Then I tried using the addresses
with them. That sent, but only to the first name on the list. I'll keep
experimenting!

Tom Wickerath said:
Hi Bryan,
If I use one name, it shows that name. If I use multiple names, it comes up blank.
"It" refers to Lotus Notes, correct? If so, I believe you are dealing with a Lotus Notes issue,
although I'm not positive....

I would experiment with some concatenated forms of known good names when addressing messages in
Lotus Notes. Perhaps you can find some documentation in Lotus Notes that covers this information.
For example, if you add my name and e-mail address, and your name and e-mail address, to the
Lotus Notes address book, which form of a concatenated string works (if any):

1.) Bryan; Tom Wickerath (semi-colon only delimited)
2.) Bryan, Tom Wickerath (comma only delimited)
3.) 'Bryan'; 'Tom Wickerath' (semi-colon delimited with single quote around each value)
4.) 'Bryan', 'Tom Wickerath' (comma delimited with single quote around each value)
5.) "Bryan"; "Tom Wickerath" (semi-colon delimited with double quotes around each value)
6.) "Bryan", "Tom Wickerath" (comma delimited with double quotes around each value)

What about:
7.) Bryan; Wickerath Tom (semi-colon only delimited with last name first)
8.) Bryan; Wickerath, Tom (semi-colon only delimited with last name first + comma
separating last & first names)

Since I don't know your last name, I cannot include it in the examples above.

Do you have Outlook or Outlook Express available on a test machine? If so, try setting one of
these e-mail clients as the default MAPI client. Enter some known good names into the address
book and then repeat the experiment. If it works then you've pretty much verified that it is a
Lotus Notes issue. Can you get any support from IBM on Lotus Notes issues, or is there a
newsgroup available for this software that you can post a question to? It sounds like it is
having an issue resolving multiple names. When controlled through automation, it appears to be
treating a concatenated list as one name. When the user interacts manually, it appears to resolve
the concatenated list correctly. This is the only explanation that I have for your observation
that "I
rechecked notes by manually inserting the list exactly as shown in the debug screen and that
works." Perhaps Lotus Notes needs the equivalent of this block of code shown in KB 209948 for
Outlook, when controlled via automation:

http://support.microsoft.com/?id=209948

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next


Please follow-up with anything new that you learn. Perhaps tonight I can find time to modify the
rest of your current sendEmail procedure to work with Outlook and Outlook Express, and then test
it on my end. I have to get ready for work right now.

Tom
___________________________________


Tom,

Sorry to bother you again, but it is not working as well as I had hoped. I
looked at your Debug screen and it looked great. I inserted only my own name
in the form and it worked great. I did not try to insert several names until
late yesterday when I had the report finished. I got back an error message
saying, "Unable to send mail, no match found in Name & Address book(s)." I
rechecked notes by manually inserting the list exactly as shown in the debug
screen and that works. This morning I got the idea to change your debug to
Debug.Print Recipients in the sendemail module and guess what? If I use one
name, it shows that name. If I use multiple names, it comes up blank. So
the bulkEmail module works, but the code in the sendEmail doesn't. Any
ideas??

___________________________________

Tom Wickerath said:
Hi Bryan,

I'm happy to hear that you got it working!

Thanks for the nice compliment. Good luck in your studies and application of database
normalization techniques.


Tom
____________________________________


That did it!! Thanks, Tom, for all of your help. I also appreciate the
extra info. I am reading all that you enclosed on normalization. Although I
have built several DBs, I have never had to use e-mail. I have learned more
from you in the last 2 days than I have in the past year. Thanks for your
patience and wisdom!

Bryan
____________________________________

:

Hi Bryan,

The only way that I can reproduce your observation is if one or more of the fields that you are
using to store names in is either null or a zero-length string (ie. ""). If this is the case,
then replace the SQL statement for quniAllRecipients with the statement shown below.

Also, I added an If....Then / End If to Private Sub sendemail, which will cause the record to
be
saved if it is dirty (pencil symbol displayed in record selector, assuming you have the record
selector visible on the form). This way, you will see the result immediately, without
having
to
navigate off of the record to save it and then return to this record to select it.


Private Sub sendemail_Click()
On Error GoTo ProcError

If Me.Dirty Then
Me.Dirty = False
End If

Dim Recipients As String, strBody As String

<rest of code goes here>

Tom

********************************
New quniAllRecipients:

SELECT [Originator] AS Recipient FROM Table1
WHERE (((Table1.[Originator]) Is Not Null
AND (Table1.[Originator])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Engineer Name] AS Recipient FROM Table1
WHERE (((Table1.[Engineer Name]) Is Not Null
AND (Table1.[Engineer Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Manufacturing and Test Name] AS Recipient FROM Table1
WHERE (((Table1.[Manufacturing and Test Name]) Is Not Null
AND (Table1.[Manufacturing and Test Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Master Scheduler Name] AS Recipient FROM Table1
WHERE (((Table1.[Master Scheduler Name]) Is Not Null
AND (Table1.[Master Scheduler Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [Procurement Name] AS Recipient FROM Table1
WHERE (((Table1.[Procurement Name]) Is Not Null
AND (Table1.[Procurement Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))
UNION

SELECT [P&L Managers Name] AS Recipient FROM Table1
WHERE (((Table1.[P&L Managers Name]) Is Not Null
AND (Table1.[P&L Managers Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]))

UNION SELECT [Quality Name] AS Recipient FROM Table1
WHERE (((Table1.[Quality Name]) Is Not Null
AND (Table1.[Quality Name])<>"")
AND ((Table1.[ECR Number])=[Forms]![frmECN]![ECR Number]));

________________________________________


Hey Tom,

I really appreciate your insights. The code works, with only one bug. The
union query returns the first row as null or empty. What I end up with is
";Bryan Daniels" in my debug window. My email then doesn't recognize the
"name" which it sees before the ;
Any idea how to eliminate the empty row?
My Error is "Unable to send mail, not match found in name and address book(s)"
I purposely left only my own name in the form to test, because I knew that
worked.
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top