473,770 Members | 3,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS Access Send To recipient (not as attachment but as HTML)

Hi... I want to use the macro/sendobject (or any other
procedure) to send the contents of a table (very small, ~5
rows/columns) as an Outlook message body, not as an
attachment. Access 2000 will not allow "Send To Mail
Recipient" (as opposed to "send as attachment") for
tables. Needless to say, every other MS application
(Word, Excel, etc) let's me send anything I want as a
message body. Outlook lets me import anything as a
message body; I can drag and drop the table from Access to
Outlook as a message body. Any ideas on how to automate
this task? (by the way, the "macro" to send the table as
an email body would run once a day...I don't want the
recipients to have to open a tiny text attachment every
day) Thanks!!!

Dec 21 '05 #1
5 2456
obvious answer - automate outlook.
http://www.amazecreations.com/datafa...utlookmail.asp

Dec 21 '05 #2
Mate this works fine for mail if you are sending an attachment but if I
want to send the dataset in a mail as part of the body of the message

Dec 22 '05 #3
If you have Windows 2000 or greater, if you have not removed your ADO
references, if you add a CDO reference , if you make the replacements
in code carefully, if you correct the line breaks inserted by
newsreaders this is likely to do what you describe as wanting to do
silently and fusslessly:

Public Sub VerySimpleSendM ailWithCDOSampl e()
' requires reference to cdosys.dll

Dim iCfg As CDO.Configurati on
Dim iMsg As CDO.Message

Set iCfg = New CDO.Configurati on
Set iMsg = New CDO.Message

With iCfg.Fields
..Item(cdoSendU singMethod) = cdoSendUsingPor t
..Item(cdoSMTPS erverPort) = 25
..Item(cdoSMTPS erver) = "SMTP.SomeDomai n.Com"
..Item(cdoSMTPA uthenticate) = cdoBasic
..Item(cdoSendU serName) = "UserName"
..Item(cdoSendP assword) = "PassWord"
..Item(cdoSendE mailAddress) = "Some One<So*****@Som eDomain.Com>"
..Update
End With

With iMsg
..Configuration = iCfg
..Subject = "Whatever"
..To = "Re*******@Some OtherDomain.com "
..TextBody = CurrentProject. Connection.Exec ute("SELECT * FROM
FirstTable").Ge tString(adClipS tring, , vbTab, vbNewLine, "")
..Send
End With

Set iMsg = Nothing
Set iCfg = Nothing

End Sub

Dec 22 '05 #4
Sean
You have asked me about this by e-mail. I have lost your e-mail
address.
You have pointed out that what you REALLY want to do is send a report
as html.
When Access outputs reports as HTML is does so as multiple files, one
for each page of the report.
The following Procedure tries to deal with those conditions. I have
tested it only with the report "Products By Category" in the Northwinds
Database.
It's very doubtful if this procedure will be sufficient in all cases or
even the majority of cases. But it's code; it can be modified to meet
specific needs.
---
In another thread some posters have indicated a problem with connecting
to the SMTP server. My only suggestion is to check the UserName
requirements; with Yahoo only the username is required, while with many
other servers the entire e-mail address is required. Beyond that lie
questions about smtp, the internet, firewalls etc. These are also
beyond the scope of this question.
---

Option Explicit

Public Sub SendReportAsHTM L( _
ByVal ReportName As String, _
ByVal SMTPServer As String, _
ByVal SendUserName As String, _
ByVal SendPassword As String, _
ByVal SendEmailAddres s As String, _
ByVal Subject As String, _
ByVal Recipients As String)

Dim Buffer As String
Dim Position As Long
Dim FileNumber As Integer
Dim HTML As String
Dim HTMLFullPath As String
Dim iCfg As Object
Dim iMsg As Object
Dim Skelton As String
Dim TempDirectory As String
Dim Truncate As Long

Set iCfg = CreateObject("C DO.Configuratio n")
Set iMsg = CreateObject("C DO.Message")

Skelton = Format(Now(), "mmmddyyyyhhnns s")
TempDirectory = Environ$("temp" ) & "/"
HTMLFullPath = TempDirectory & Skelton & ".html"

DoCmd.OutputTo acOutputReport, ReportName, acFormatHTML, HTMLFullPath

HTMLFullPath = Dir$(TempDirect ory & Skelton & "*.html")
While Len(HTMLFullPat h) <> 0
HTMLFullPath = TempDirectory & HTMLFullPath
FileNumber = FreeFile()
Open HTMLFullPath For Binary As #FileNumber
Buffer = String(LOF(File Number), vbNullChar)
Get #FileNumber, , Buffer
Close #FileNumber
Position = InStr(Buffer, "</TABLE>")
While Position <> 0
Truncate = Position
Position = InStr(Truncate + 1, Buffer, "</TABLE>")
Wend
HTML = HTML & Left(Buffer, Truncate + 7)
HTML = HTML & "<hr>"
Kill HTMLFullPath
HTMLFullPath = Dir$()
Wend

With iCfg.Fields
..Item("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2
..Item("http://schemas.microso ft.com/cdo/configuration/smtpserverport" )
= 25
..Item("http://schemas.microso ft.com/cdo/configuration/smtpserver") =
SMTPServer
..Item("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e")
= 1
..Item("http://schemas.microso ft.com/cdo/configuration/sendusername") =
SendUserName
..Item("http://schemas.microso ft.com/cdo/configuration/sendpassword") =
SendPassword
..Item("http://schemas.microso ft.com/cdo/configuration/sendemailaddres s")
= SendEmailAddres s
..Update
End With
With iMsg
..Configuration = iCfg
..Subject = Subject
..To = Recipients
..HTMLBody = HTML
..Send
End With

Set iMsg = Nothing
Set iCfg = Nothing

Close

End Sub

Dec 29 '05 #5
Hey Lyle,
Thanks very much re this.
It worked fine after as you say a few adaptions
Cheers Mate

*** Sent via Developersdex http://www.developersdex.com ***
Feb 1 '06 #6

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

Similar topics

40
11898
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the following import win32com.client
10
5572
by: MLH | last post by:
I print to a device that creates a PDF. Knowing the filename, how can I then embed the PDF into the body text of an OutLook Express outbound email & send to a specified address in a table? I want recipient addressees to see the report in the body text window of their email when they open it. I was thinking also about attaching the PDF file to the eMail for those having "text only" email software. I need to automate both of these tasks from...
19
2802
by: Bill | last post by:
I have searched through the posts for a question like mine but have only found much more complicated responses. On single record view of a form I have an email address field. I merely want to create a button that will email the same message (and idealy a word attachment) to whatever address is in view on the form (chances are that I just input it). For further explanation:
1
2150
by: kathyk | last post by:
Hi, I created an application in MS Access 2000. Since upgrading to MS Access 2003 I have been finding all sorts of strange things. My current problem is with the function below. Ig get an error "429 ActiveX Componant Can't Create Object" How can I correct this error? Thanks very Much! Kathy Here is the function: ' By Glen Appleton found in Google Group
5
2977
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
10
24394
by: Mike Charney | last post by:
Is there a simple way to send SMTP email from Access VBA? Mike m charney at dunlap hospital dot org
16
6200
by: Kosmos | last post by:
Good afternoon everyone, just wondering if anyone knew if it's possible to send meetings or appointments through email when you run VBA or SQL code in Access 2003? The following is the code I've been using which sends If you want to see the above code in its full context you can see it here: http://www.thescripts.com/forum/thread581521.html Willakawill helped me out a bit with getting access to remember if it had already added the...
2
3673
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain contracts and then it adds them to the outlook calendar of the current user. This code works and is nested within a bunch of if statements because it only needs to trap certain appointments. The table I create with this code is later used to attempt to...
6
10640
by: dlblack | last post by:
I am using the following code to send emails with attachments from Access using Outlook. The code works fine if Outlook is already open and emails are sent as expected via Outlook. When Outlook is closed, data is saved to the database but the email is not sent. Here is the the code. If anyone has suggestions on how I can get Outlook to open before trying to send the email I would appreciate it. Private Sub Approve_Click() On Error GoTo...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.