Solved

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

Posted on 2006-11-01
7
289 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 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