Solved

Access 2003 - sending a body of an email with a report?

Posted on 2006-11-01
7
290 Views
Last Modified: 2008-03-10
Hi All,

I have an email system set up with my access reports that works fine but I wan to add in a long letter to the body of the email not as an attachment like the report is at the moment.

So at the moment this is how it is:

'set variables
                sMsgSubject = "1MthAfter"
                sMsgBody = "Dear Licensee Representative:" & Chr(13) & "Please see attached 1MthAfter not at the endlin"    
                DoCmd.OpenReport "1MthAfter", acPreview                              
                'DoCmd.SendObject acSendReport, "1MthAfter", cSNPFormat, rstReportDetails![Email], , , sMsgSubject, sMsgBody, False

The aove works fine if what I have to say in the body of the email isn't too long. But when I run out of space along that line and have to go to another line that is where to problems start to happen.
So I tried something like this but it gave me errors:


sMsgBody = "Dear Licensee Representative:" & Chr(13) & "Please see attached 1MthAfter when i came to the end of "   
sMsgBody  = sMsgBody & " the line and i continued with the body of the email on this line but it made no difference"      


When I ran the report and went to email it, It only email the first line as the body and not both lines? Can anyone help? How so I email the full body in an email that I hard code into the code.

Thanks again
                               
0
Comment
Question by:sabrina_spillane
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:mpmccarthy
ID: 17853970
Change to ...

sMsgBody = "Dear Licensee Representative:" & vbCrLf & "Please see attached 1MthAfter when i came to the end of "
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17854097
you could also store your full body text into a table inside a memo field, then pull the whole thing in with a DLookup. That way you don't have to hard code it into the text...just change the words anytime you want in the memo field.

J
0
 

Author Comment

by:sabrina_spillane
ID: 17858457
I can't just have the sMsgBody like that because what i want to say goes over multiple lines in the VBA. That is my problem I run out of space in the one line and i need to go to the next line. So just one sMsgBody won't work as I need to continue to the next line. Do you know what I mean.

sMsgBody = "Dear Licensee Representative:" & vbCrLf & "Please see attached 1MthAfter when i came to the end of  and I continue on here till the end of the line and then i run of off space and i need to continue to this line but if i have nothing in the begining of the line it will throw an error."

Can anyone help.

I don't want to create another table in the database just for this.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:sabrina_spillane
ID: 17860543
Has anyone any other options on this matter, thanks.
0
 
LVL 9

Assisted Solution

by:mpmccarthy
mpmccarthy earned 50 total points
ID: 17861132
sMsgBody = "Dear Licensee Representative:" & vbCrLf & "Please see attached 1MthAfter when i came to the end of  and I continue on here till the end of the line and then i run of off space and i need to continue to this line but if i have nothing in the begining of the line it will throw an error."

I don't understand.  All vbCrLf will do is create a line down.  How is this throwing an error?  You can put as many of them as you want in a string body.
0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 200 total points
ID: 17861274
This worked fine

    Dim sMsgBody As String
    sMsgBody = "Dear Licensee Representative:" & Chr(13) & "Please see attached 1MthAfter when i came to the end of "
    sMsgBody = sMsgBody & " the line and i continued with the body of the email on this line but it made no difference"


What e-mail program are you using? Check your settings, and make sure you're sending HTML as an output format.

J
0
 

Author Comment

by:sabrina_spillane
ID: 17862964
Hi all,

Thanks for the quick response believe it or not the following worked even though I had tried that before hand and it through an error but thankfully it is working now. I must have been missing something.

Dim sMsgBody As String
    sMsgBody = "Dear Licensee Representative:" & Chr(13) & "Please see attached 1MthAfter when i came to the end of "
    sMsgBody = sMsgBody & " the line and i continued with the body of the email on this line but it made no difference"

Thanks again
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question