Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old December 12th 04, 04:03 PM posted to microsoft.public.excel.programming,microsoft.public.office.developer.outlook.vba
external usenet poster
 
First recorded activity by ExcelBanter: Dec 2004
Posts: 1
Default Late Binding to Outlook from Excel: Outlook modifies email body

Hi,

I have the following problem sending long strings in the body of an
email (via Outlook) from an Excel vba program. Here are the details:

I've got a vba program in Excel that obtains data from a variety of
locations in several spreadsheets. The program creates comma delimited,
CRLF terminated records, and emails the records in the body of an email.
Emailing is handled by late binding to Outlook.

Each record ranges from about 90 to 140 characters long. The complete
set of records (the body of the email) is 4-6K bytes. The records each
end in <CRLF (e.g. &H0D, &H0A). I'm certain that the records are well
formed (I know this because I also write the string comprising the body
of the email to a local file that I open (with VBA)in binary mode. I
verfy the file by opening it in both binary and text mode using the MS
Visual Studio editor, and it looks perfect).

The problem is that Outlook (or the Autoamtion interface to Outlook)
insists on modifying the body of the email, by adding extra CRLF's
and/or wrapping lines. I also find that the recipient client (also
Outlook) likes to somtimes help out by deleting some CRLF's to "help me
out"!!

I have the following constraint imposed on me by my users: The data
must be whole records in the body of an email.

My main question is: Is there a way to send these rather long lines
using late binding to the Outlook Automation interface without Outlook
(or its interface) modifying what I give it? If not I'll have to go
seach for a 3rd party VBA email library to use instead of Outlook; but
it seems to me that Outlook should be able to do this (as I read it, RFC
2821 says lines can be 1000 characters long and email bodies can be 64
K).

Here is the code on the Excel side that interfaces to Outlook. "Body" is
a string containing all the records with CRLF's inserted bytewise by
another VBA Sub. "CCRecipient" is not used in the code any more, because
I have not been able to get late binding to the Outlook Autoamtion
object to accept a CC recipient. This function always returns True, for
now.

Public Function SendEMail(Recipient As String, CCRecipient As String,
Subj As String, Body As String) As Boolean
Dim App As Object
Dim Mail As Object

Set App = CreateObject("Outlook.Application")
Set Mail = App.CreateItem(0)
With Mail
.Subject = Subj
.Recipients.Add (Recipient)
.BodyFormat = 1 'olFormatPlain
.Body = Body
End With
Mail.Send

Set Mail = Nothing
Set App = Nothing

SendEMail = True
End Function

Any help getting Outlook to just take what I give it and send it as
given will be greatly appreciated.
Extra points to anyone who can also help me figure out why I can't enter
a CC recipient :-) (That code is no longer present in the above
function, but it consisted of doing another .Recipeints.Add and
following that with setting the recipient type to the numerical value of
the olTypeCC manifest constant.)

Thanks in advance for any help.

Lenny Wintfeld
(long time C/C++ programmer, currently figuring out what VBA is about)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending a Mail from outlook with body coming from excel file PauloD Excel Discussion (Misc queries) 1 November 11th 10 01:59 PM
Send a Sheet as body of Outlook Email David Ackerman on cape cod Excel Discussion (Misc queries) 0 March 19th 10 03:11 PM
Excel(with hyperlinks) as a message body of outlook mail hans Excel Discussion (Misc queries) 1 July 7th 06 12:35 PM
How to paste cells from Excel into Outlook email body? stastim Excel Programming 2 August 23rd 04 06:35 PM
Creating a MailItem in Outlook from Excel using Late Binding Steven Kelder Excel Programming 3 December 17th 03 05:34 PM


All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017