473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

emailing from a form

I have a table called Contact_Info. I have a form that allows me to show
all the contacts from a specified city and sector. Once these contacts
appear on my new form I would like to be able to press a button and it would
take their email addresses, from the 'email' field, and enter them into
Outlook in the "TO:" box so that they can all be emailed the same document.
Any help would be much appreciated, thank you,
Brendan

--
Disclaimer: Any comments made are personal and do not reflect the thoughts
or policies of this company.
Nov 12 '05 #1
9 2218
First you will need to add a reference to Microsoft Outlook in your VBA
editor, then use this code in an event.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = New Outlook.Application
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.Recipients.Add ("john doe")
.BodyFormat = 1 '1 for text, 2 for html
.Subject = "My Subject"
If iFormat = 2 Then
.HTMLBody = Message
Else
.Body = "My Message" 'can use vbCrLf if you want line breaks
above or below
End If
SendEmail = True
.Display 'if you want to show it, doe this, otherwise leave it off
End With
Set objOutlook = Nothing

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Brendan MAther" <br************@gems4.gov.bc.ca> wrote in message
news:3f********@obsidian.gov.bc.ca...
I have a table called Contact_Info. I have a form that allows me to show
all the contacts from a specified city and sector. Once these contacts
appear on my new form I would like to be able to press a button and it would take their email addresses, from the 'email' field, and enter them into
Outlook in the "TO:" box so that they can all be emailed the same document. Any help would be much appreciated, thank you,
Brendan

--
Disclaimer: Any comments made are personal and do not reflect the thoughts
or policies of this company.

Nov 12 '05 #2
Hello,

(I am not sure if this is going to Jerry or not but he replied to the
previous message)
I have a similar problem. However, I have a report that I want to email
to vendors. It is an outstanding report so therefore each report is
different. On the report I have Co. info such as ph, fax email. The
report depepends on how many vendors are past due but is usually about
50 separate pages. Is there a way to send the report to their owners
and each one as a totally separate email? I use Lotus Notes.

Thank you,
TJ

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Thanks jerry, but how can I make it so that it will grab all the email
addresses in that form and put them all in the same email in the TO: box?
I tried .Recipients.Add (Forms!ListCommCity!email), i also tried
ListCommCity.email and ListCommCity.[email]. It will only list whichever
contact is selected, by default that is the first contact in the form.

thanks,

Brendan

"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:uD*****************@newssvr23.news.prodigy.co m...
First you will need to add a reference to Microsoft Outlook in your VBA
editor, then use this code in an event.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = New Outlook.Application
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.Recipients.Add ("john doe")
.BodyFormat = 1 '1 for text, 2 for html
.Subject = "My Subject"
If iFormat = 2 Then
.HTMLBody = Message
Else
.Body = "My Message" 'can use vbCrLf if you want line breaks
above or below
End If
SendEmail = True
.Display 'if you want to show it, doe this, otherwise leave it off
End With
Set objOutlook = Nothing

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Brendan MAther" <br************@gems4.gov.bc.ca> wrote in message
news:3f********@obsidian.gov.bc.ca...
I have a table called Contact_Info. I have a form that allows me to show all the contacts from a specified city and sector. Once these contacts
appear on my new form I would like to be able to press a button and it

would
take their email addresses, from the 'email' field, and enter them into
Outlook in the "TO:" box so that they can all be emailed the same

document.
Any help would be much appreciated, thank you,
Brendan

--
Disclaimer: Any comments made are personal and do not reflect the thoughts or policies of this company.


Nov 12 '05 #4
You will have to loop through the listbox and call the add method each time.

So... something like this would need to be incorporated, this example works
on just the items you would select in the list... (if you want all of them
every time, then you will need to use different properties to iterate
through the list, you will have to do the looking on that one though).

.....
For Each Item In Me.myList.ItemsSelected
.Recipients.Add (Me.myList.ItemData(Item))
Next
......

Let me know how it turns out... ok?

:)

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Brendan MAther" <br************@gems4.gov.bc.ca> wrote in message
news:3f********@obsidian.gov.bc.ca...
Thanks jerry, but how can I make it so that it will grab all the email
addresses in that form and put them all in the same email in the TO: box?
I tried .Recipients.Add (Forms!ListCommCity!email), i also tried
ListCommCity.email and ListCommCity.[email]. It will only list whichever
contact is selected, by default that is the first contact in the form.

thanks,

Brendan

"Jerry Boone" <je***@antech.biz.killspam> wrote in message
news:uD*****************@newssvr23.news.prodigy.co m...
First you will need to add a reference to Microsoft Outlook in your VBA
editor, then use this code in an event.

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = New Outlook.Application
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.Recipients.Add ("john doe")
.BodyFormat = 1 '1 for text, 2 for html
.Subject = "My Subject"
If iFormat = 2 Then
.HTMLBody = Message
Else
.Body = "My Message" 'can use vbCrLf if you want line breaks
above or below
End If
SendEmail = True
.Display 'if you want to show it, doe this, otherwise leave it off
End With
Set objOutlook = Nothing

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Brendan MAther" <br************@gems4.gov.bc.ca> wrote in message
news:3f********@obsidian.gov.bc.ca...
I have a table called Contact_Info. I have a form that allows me to

show all the contacts from a specified city and sector. Once these contacts appear on my new form I would like to be able to press a button and it

would
take their email addresses, from the 'email' field, and enter them into Outlook in the "TO:" box so that they can all be emailed the same

document.
Any help would be much appreciated, thank you,
Brendan

--
Disclaimer: Any comments made are personal and do not reflect the thoughts or policies of this company.



Nov 12 '05 #5
Possibly... that is if access can produce a Notes email using menu options
like Send To... otherwise, sorry - get Outlook running! :)

This will output a report object to an email...

DoCmd.SendObject acSendReport, "myReport", acFormatSNP,
"so*****@somewhere.com", , , , , True

You should then run this code for each separate email address.
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access


"Tony Johnson" <et*@wt.net> wrote in message
news:3f*********************@news.frii.net...
Hello,

(I am not sure if this is going to Jerry or not but he replied to the
previous message)
I have a similar problem. However, I have a report that I want to email
to vendors. It is an outstanding report so therefore each report is
different. On the report I have Co. info such as ph, fax email. The
report depepends on how many vendors are past due but is usually about
50 separate pages. Is there a way to send the report to their owners
and each one as a totally separate email? I use Lotus Notes.

Thank you,
TJ

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #6
Tony Johnson <et*@wt.net> wrote:
Is there a way to send the report to their owners
and each one as a totally separate email?
See the Recordset Looping Logic page at the top of the Access Email FAQ at my
website.
I use Lotus Notes.


See the Lotus Notes specific links on the same page mentioned above.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #7
"Brendan MAther" <br************@gems4.gov.bc.ca> wrote in message news:<3f********@obsidian.gov.bc.ca>...
Thanks jerry, but how can I make it so that it will grab all the email
addresses in that form and put them all in the same email in the TO: box?
I tried .Recipients.Add (Forms!ListCommCity!email), i also tried
ListCommCity.email and ListCommCity.[email]. It will only list whichever
contact is selected, by default that is the first contact in the form.


I'm assuming you have the Multi-Select property of your listbox set to
Extended... You have to iterate through the ItemsSelected collection
of the listbox and then do something with them...

from: http://www.mvps.org/access/forms/frm0007.htm

Q) I have a MultiSelect listbox control on my form. I want to pass the
selected items to a query as a parameter. How do I do this?

(A) Unlike simple listbox controls which can be referenced as a
parameter by a query, MultiSelect listboxes cannot be used directly as
a parameter. This is because calling the listbox
(Forms!frmMyForm!lbMultiSelListBox) from anywhere will not
automatically concatenate all the selected items. You need to build
the criteria yourself.

Note: You can still use a parameterized query provided you pass the
entire Where clause to it via code as a parameter. (eg. Have the query
reference a hidden control to which you manually assign the complete
WHERE clause using the following logic.)

For example,

'******************** Code Start ************************
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox
strSQL = "Select * from Employees where [EmpID]="
'Assuming long [EmpID] is the bound field in lb
'enumerate selected items and
'concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [EmpID]="
Next varItem

'Trim the end of strSQL
strSQL=left$(strSQL,len(strSQL)-12))
'******************** Code end ************************
Okay, so in your case...

dim ctl as control
set ctl = me!lbAddresses
For Each varItem in ctl.ItemsSelected
olkMsg.Recipients.Add ctl.ItemData(varItem)
Next varItem
'create the rest of the message...
'(you know how to do that, I presume)
'then send
olkMsg.Send
Nov 12 '05 #8
Tony Johnson <et*@wt.net> wrote in message news:<3f*********************@news.frii.net>...
Hello,

(I am not sure if this is going to Jerry or not but he replied to the
previous message)
I have a similar problem. However, I have a report that I want to email
to vendors. It is an outstanding report so therefore each report is
different. On the report I have Co. info such as ph, fax email. The
report depepends on how many vendors are past due but is usually about
50 separate pages. Is there a way to send the report to their owners
and each one as a totally separate email? I use Lotus Notes.

Thank you,
TJ


Have a look at the E-mail section of Tony Toews' site...
http://www.granite.ab.ca/access/emaillotusnotes.htm

I *think* you may have to output the report to RTF or something and
then attach it. So *maybe* you have to base your report on a dummy
query that you modify on the fly, because at least in 2000, if you
sent a filtered report, the filter somehow got ignored and the whole
report got output...
Nov 12 '05 #9
pi********@hotmail.com (Pieter Linden) wrote:
I *think* you may have to output the report to RTF or something and
then attach it. So *maybe* you have to base your report on a dummy
query that you modify on the fly, because at least in 2000, if you
sent a filtered report, the filter somehow got ignored and the whole
report got output...


Or as per "Emailing reports as attachments from Microsoft Access"

However you can not pass a filter or where clause as you would in a standard
OpenReport command in VBA. Therefore you must change the filter or where clause
yourself in the reports OnOpen event.

Me.Filter = "ShipmentsID=" & Forms![Select Load List]![LoadID]
Me.FilterOn = True

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steven Scaife | last post by:
There seems to be a problem with my emailing code, although during testing it worked fine. What happens is it sends two emails instead of one, and also doesn't put any text in the email for some...
2
by: Chuck | last post by:
I have a database that has a table in it with employee information (name, dob, email, etc). This is joined to a table that has tasks that are assigned to each individual that has a recurring date....
5
by: Colin Anderson | last post by:
I discovered, with great excitement, this article http://www.davison.uk.net/vb2notes.asp when researching methods for emailing from Access via Notes. Unfortunatly, when I run this I get a...
1
by: Alfie | last post by:
I've got a form, and I'm trying to set up a way of emailing from it. Does anyone know, if I've got an email address in a field called , is there a way that I could create a command button which,...
2
by: Paul Wilson | last post by:
Hi guys, In classic ASP, i used to enable emailing from a webpage using the following code, lcData = "mailto:?CC=" + lcCC + "&subject=" + lcSubject + "&body=" + lcBody...
4
by: Mike Moore | last post by:
What is the best way to launch outlook from an asp.net web page? Can you do this using MAPI or is there a control that you can purchase? We are unable to use SMTP. We use MS Exhange and MAPI...
1
by: dman | last post by:
Hi, I am a total newbie to asp.net. I have spent the last week or so trying to find a good tutorial that would show me how to create a form that would be entered into a SQL database and then...
0
by: paulhux174 | last post by:
Emailing a web page to several addresses Hi, I need to send the contents of a web page to several email addresses (4). Some elements of the Form I want to hide for some and some elements of the...
1
by: crisostomofred | last post by:
I have a report with it's source from a query. The query calls data from 3 related tables. The report is a meeting agenda and I only want to attach a snapshot report to my email based on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.