Below is a sample of my code which is used to populate a message that must be e-mailed. When outlook comes up, it is seen in the proper format and shows the carriage returns as was formatted by my code. When the message is sent, I lose the carriage returns.
Can anyone help me with this one? Why is outlook defaulting to plain text when I use the sendobject command?
c1 = " The following purchase requisition requires additional approval due to the following reason: "
c1b = " [indicate with an X all that apply]"
c2 = " [ ] Air Conditioners (DC and Facilities)"
c3 = " [ ] Clothing And Jackets(FDC)"
c4 = " [ ] Food Purchases (DC)"
c5 = " [ ] Furniture(DC And Facilities)"
Msg = Chr(13) & c1 & Chr(13) & c1b & Chr(13) & Chr(13) & c2 & Chr(13) & c3 & Chr(13) & c4 & Chr(13) & c5 & Chr(13)
This is probably true, but all I know is I have the option to change my outlook output from plain text to html. This has not been restricted by my agency's network administrators. When I do this change, it holds the proper formatting of the text. That is all I am trying to do. There are no hyperlinks in the message or pictures in the message.
The constant acFunction does exist in Access 2003. It is a member of the AcObjectType class and its value is 10 (decimal). You're receiving this error because the next parameter is empty:
DoCmd.SendObject acFunction, "",...
The Access help system (type SendObject in the search window) explains that the SendObject method is used to include an Access object that can be a Datasheet, a Form, a Report, a Module or a Data Access Page into an Electronic Message.
An Access function (acFunction) does not seem to be a valid type of object for the SendObject method, and moreover the name of the object is left blank ("") in your code.
You can always use Automation to work with Outlook. Here is an example:
' Send an email using Outlook Automation:
Dim l(0 To 10) As String
Dim lx As String
Dim i As Integer
' You must create a reference to the Outlook library
' (For Office 2003: Menu Tools --> References Microsoft Outlook 11.0 Object Library")
' if you want to declare Outlook objects like this (early binding):
Dim appOutlook As Outlook.Application
Dim oItem As Outlook.MailItem
Set appOutlook = New Outlook.Application
' You can also use late binding variables
' (no reference needed but less efficient):
' Dim appOutlook As Object
' Dim oItem As Object
' Set appOutlook = CreateObject("Outlook.Application")
' Create some arbitrary set of lines that will constitute the body of the message:
For i = 1 To 10
l(i) = Format(i, "0#") & " ejrioavv effjzfjzfioze,cvze fz ofozeifzjejz."
lx = lx & l(i) & vbNewLine
' Create an Outlook MailItem (i.e. a new message):
Set oItem = .CreateItem(olMailItem)
' Fill in some of the new message components:
.To = "email@example.com"
.Subject = "Test Outlook automation"
.Importance = olImportanceHigh
.BodyFormat = olFormatHTML
.Body = lx
' To display the message:
' To send the message use:
' Clean up
Set appOutlook = Nothing
I appreciate your help... I had done the latter part of what you showed in your code. I finally got it to work. The problem with the carriage return not holding had nothing to do with the HTML in outlook. I was using "[ ]" in my string expression as a checkoff box. For some odd reason, when it would initiate the e-mail, the carriage returns would be present, but when you sent it you would lose them. I changed those characters to a "-" and this fixed the problem.
I will still try what you sent me just in case there is additional text formatting that would require the html setting.