![]() |
|
|
| Subject:
MS Access question
Category: Computers > Programming Asked by: ratan-ga List Price: $5.00 |
Posted:
10 Apr 2003 08:52 PDT
Expires: 10 May 2003 08:52 PDT Question ID: 188808 |
I have a report (similar to an invoice) generated by the program Access that I would like to send via email from the same window of the report ( in Access) in a manner that will preserve the formatting of the report and NOT send it as an attachment in the email ( in other words, the report must appear with the original formatting intact in the body of the email.) Please advise how this can be done. I use Outlook Express as my email client. |
|
| There is no answer at this time. |
|
| Subject:
Re: MS Access question
From: hammer-ga on 11 Apr 2003 12:32 PDT |
You use OutputTo to output your report to a text file, then you use
Outlook automation to read it back in and make an Outlook message with
it. Here is an example of doing this with an HTML file from a
newsgroup posting by Lyle Fairfield.
Sub test()
sendHTML "C:\My Documents\Interdev\WebCalendar\WebCalendar_Local
\popUpCalendar.htm"
End Sub
Sub sendHTML(vStrPath As String)
Dim cSME As New clsSendMailEarly
Dim lngFileNumber As Long
Dim strHTML As String
strHTML = String(FileLen(vStrPath), vbNullChar)
lngFileNumber = FreeFile()
Open vStrPath For Binary As #lngFileNumber
Get #lngFileNumber, , strHTML
Close #lngFileNumber
With cSME
.DeleteAfter = True
.MessageHTMLBody = strHTML
.Recipients = "Lyle Fairfield"
.Subject = "PopUp Calendar Script"
.send
End With
Set cSME = Nothing
End Sub
' clsSendMailEarly
' Early Bound (the literal constants ae probably unnecessary here
' but this is a midification of a later bound class where they are
Option Compare Database
Option Explicit
Const conMailItem As Byte = 0
Const conMailTo As Byte = 1
Dim OLApp As outlook.Application
Dim OLMsg As outlook.MailItem
Dim OLRcp As outlook.Recipient
Dim OLAtt As outlook.Attachment
Private Sub Class_Initialize()
Set OLApp = CreateObject("Outlook.Application")
Set OLMsg = OLApp.CreateItem(conMailItem)
End Sub
Private Sub Class_Terminate()
Set OLAtt = Nothing
Set OLRcp = Nothing
Set OLMsg = Nothing
Set OLApp = Nothing
End Sub
Property Let Recipients(ByVal vStrRecipients As String)
Set OLRcp = OLMsg.Recipients.Add(vStrRecipients)
OLRcp.Type = conMailTo
OLMsg.Recipients.ResolveAll
End Property
Property Let Attachment(ByVal vStrAttachmentPath As String)
On Error Resume Next
If Err = 0 And Len(Dir(vStrAttachmentPath)) <> 0 Then
Set OLAtt = OLMsg.Attachments.Add(vStrAttachmentPath)
OLAtt.Position = 0
End If
On Error GoTo 0
End Property
Property Let Subject(ByVal vStrSubject As String)
OLMsg.Subject = vStrSubject
End Property
Property Let MessageBody(ByVal vStrMessageBody As String)
OLMsg.Body = vStrMessageBody
End Property
Property Let MessageHTMLBody(ByVal vStrMessageHTMLBody As String)
OLMsg.HTMLBody = vStrMessageHTMLBody
End Property
Property Let DeleteAfter(ByVal vBooDelete As Boolean)
OLMsg.DeleteAfterSubmit = vBooDelete
End Property
Sub send()
OLMsg.send
End Sub
Best regards,
- Hammer |
| Subject:
Re: MS Access question
From: ratan-ga on 11 Apr 2003 13:12 PDT |
Thanks a million, Hammer. I will try it out and update. |
| Subject:
Re: MS Access question
From: decorei-ga on 28 Apr 2003 07:48 PDT |
// Sub
Sub SendMail(From, To, Subject, Body, BodyFormat, MailFormat)
Dim CDONTS
Set CDONTS = Server.CreateObject("CDONTS.Newmail")
With CDONTS
.BodyFormat = BodyFormat
.MailFormat = MailFormat
.From = From
.To = To
.Subject = Subject
.Body = Body
.Send
End With
Set CDONTS = Nothing
End Sub
// Call
From = "from@teste.com"
To = "to@teste.com"
Suject = "Report HTML"
Body = "<html>"
Body = Body + "<body>"
Body = Body + "<table>"
Body = Body + "<tr><td><b>Column 1</b></td><td><b>Column 2</b></td></tr>"
Body = Body + "<tr><td>AAAA</td><td>BBBB</td></tr>"
Body = Body + "<tr><td>AAAA</td><td>BBBB</td></tr>"
Body = Body + "<tr><td>AAAA</td><td>BBBB</td></tr>"
Body = Body + "<tr><td>AAAA</td><td>BBBB</td></tr>"
Body = Body + "</table>"
Body = Body + "</body>"
Body = Body + "</html>"
EnviaEmail From, To, Subject, Body, 0, 0
// CDONTS
http://www.brasiliapb.vila.bol.com.br/cdonts.zip |
| Subject:
Correct URL
From: decorei-ga on 28 Apr 2003 07:54 PDT |
// CDONTS http://brasiliapb.vila.bol.com.br/cdonts.dll |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |