is there an "end" character at the end of a .body command in VBA?

M

MacNut2004

Hello,

I am asking this because I have an extremely long .body command to put into
the outlook message that is being sent from access. However, there is a limit
to the number of characters in the .body line. I need to have multiple lines
then in VBA to allow for the number of fields I am pulling from a form.

Does anyone knwo how to do this? I.e. an end character in VBA that then
looks to the next line for the continuation of the .body text?

Thanks in advance!
MN
 
D

David H

There are no 'end' characters for any property in VBA regardless of the
application that you're using. Its simply property = value.

If you've got an exceptionally long value, you can break it up using the
underscore character '_' or build the value in a string and then set the
..Body to the string.

Also, this is an Access newsgroup. While you may be automating Outlook using
Access, technically the question is an Outlook question and more appropriate
in an Outlook newsgroup.

http://www.microsoft.com/office/com...soft.public.outlook.program_vba&lang=en&cr=US
 
M

MacNut2004

Thanks David.

Well I figured it was an Access question since it's VBA within Access that
I'm working on...drafting an outlook message.

Can you tell me how i'd go about building a string within the VBA outlook
session in Access? Do i build a string witihn VBA? If so, won't i run into
the same problem with the length?

Thank you!
MN
 
D

David H

VBA is VBA regardless of the application that you're working in. When you
hear the term Access VBA, Outlook VBA, Word VBA, the term is referring to the
implementation of VBA within a specific application that lends itself to
being using directly in the application.

When you create a MailItem in Outlook VBA, there's some underlying
information that VBA already knows because its running within Outlook. When
you automate, you have to explicitly provide that information to VBA hence a
statement such as [Set objOutook = CreateObject("Outlook.Application")].

While there are some differences between Outlook VBA, Access VBA, etc, they
are quite negligible for this discussion.

Automation is the term for controlling one office application from within
another, such as what you're doing.

In terms of creating a string its basically

Dim strMailItemText as String

strMailItemText = ""
strMailItemText = strMailItemText & "Hello World"
strMailItemText = strMailItemText & Chr(13) & "Send me all your money"
strMailItemText = strMailItemText & "or your little dog dies."

objMailItem.body = strMailItemText

The code above simply builds a string by taking the exiting value of the
string and adding additional text to it. You can use the same technique with
the .Body property directly as in...

objMailItem.body = objMailItem.body & " Do not call the police."

Even though the Dim statement will set the value of strMailItemText equal to
"", I always explicitly set before a block for readability purposes and to
ensure that I'm starting with nothing.

I included the Chr(13) character to show how you can add a line return
within the body of the text.
 
D

Dirk Goldgar

MacNut2004 said:
Hello,

I am asking this because I have an extremely long .body command to put
into
the outlook message that is being sent from access. However, there is a
limit
to the number of characters in the .body line. I need to have multiple
lines
then in VBA to allow for the number of fields I am pulling from a form.

Does anyone knwo how to do this? I.e. an end character in VBA that then
looks to the next line for the continuation of the .body text?


It's not entirely clear to me what you're asking. Is it possible that all
you really want is something like this:


.Body = _
"This is a very, very, very, very, very, very, very, very, very, " &
_
"very, very, very, very, very, very, very, very, very, very, very "
& _
"long sentence."

?
 
T

Tony Toews [MVP]

MacNut2004 said:
I am asking this because I have an extremely long .body command to put into
the outlook message that is being sent from access. However, there is a limit
to the number of characters in the .body line. I need to have multiple lines
then in VBA to allow for the number of fields I am pulling from a form.

Does the following example answer your question?

strBody = "Some text here" & vbcrlf & vbcrlf & _
" more text and more text and more text " & _
" more text and more text and more text."
strBody = strBody & me.<form control name> & " more text" & _
" more text and more text and more text."

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top