Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Attachment Position 2

Status
Not open for further replies.

DougAtAvalon

Programmer
Jan 29, 2001
99
0
0
US
Whenever I automate the inserting of an attachment to an emailing messgae in Outlook from Access the Document is positioned "funny" in the middly of body and text. Is there a way to insert it on the bottom or at least direct where it will go.

-Doug
 
Doug,
I do a lot of automated email reports. I use groupwise (soon to be swithing to Lotus). I have tried everything the only thing that I can do I just change the report and keep saving it as RTF until it looks correct. I would love it someone else new of a way to make a report, saved as an RTF, look like it does on the access report. But I truly dont believe there is. But I have wondered if there is a way to save it as SNP (snap shot). That would probably work althought you will lose any kind of editting ability (as snap shot is a picture).
Scoty ::)
 
The position property determines where the file is placed. I suppose that if you have an input box to fill in the body of the message you could count the number of characters (spaces included) add one to resulting number and use this value in the position property. In the first code below I opted to use 999 that seems to give enough room for a detailed message body. The second group I use .HTMLBody with a <br> at the end of the message. This sticks the attachment into a frame on the bottom of the message. The second set of code would probably do the trick.

Hope this helps! jelwood01

Private Sub cmdSendAtt_Click()

Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject(&quot;Outlook.Application&quot;)
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.To = &quot;Buddy@Buddy.com&quot;
.Subject = &quot;TEST&quot;
.Body = &quot;TEST&quot;
.Attachments.Add &quot;C:\Stuff.doc&quot;, olByValue, 999, &quot;Proposal&quot;
.Send
End With
End Sub

Private Sub cmdSendAtt_Click()

Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject(&quot;Outlook.Application&quot;)
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.To = &quot;Buddy@Buddy.com&quot;
.Subject = &quot;TEST&quot;
.HTMLBody = &quot;TEST<br>&quot;
.Attachments.Add &quot;C:\Stuff.doc&quot;, olByValue, 1, &quot;Proposal&quot;
.Send
End With
End Sub
 
That is Great! However, there is one problem I never worked with &quot;.HTMLBody&quot; before so there are some adjustments.

1. Can you have both .HTMLBody and .Body
2. If not what do I do

This is my code. The problem is some of the variables have line breaks and I also include line breaks in the code. This way it puts it all on one line.
**************
.Subject = vSubject
.HTMLBody = vDear & &quot;,&quot; & Chr(13) & Chr(13) & vBody & &quot;<br>&quot;
Set objOutlookAttach = objOutlookMsg.Attachments.Add(vAttachment, , 1, Me.City & Me.State)
***************

This way it doesn't include my &quot;.body&quot; variables
******************
.Subject = vSubject
.Body = vDear & &quot;,&quot; & Chr(13) & Chr(13) & vBody
.HTMLBody= &quot;<br>&quot;
Set objOutlookAttach = objOutlookMsg.Attachments.Add(vAttachment, , 1, Me.City & Me.State)

By the way this opens up some good things . . .

Thanx,
Doug
 
Doug,
It is an either/or situation for the body of the message. I prefer to use .HTMLBody for the flexibility it offers.
I use the BarebonesHTML as a style guide because HTMLBody allows you to do all sorts of neat formating with colors, font sizes, etc.

The first code that you list looks good and should do the trick. With the .HTMLbody breaks, and spaces are dropped in as such:
.HTMLBody = &quot;<B>Dear &quot; & stName & &quot;,</B><br>&quot; & stMessage
This would read as:
Dear Doug,
Hello...

Play around and send the emails to yourself to hammer out the formatting. Also, take a look at the BarebonesHTML guide, it is a big help with this.

jelwood01
 
Thanks I used a replace function I have to search for Chr(13) and replace with &quot;<br>&quot; in the users input for body to keep breaks.

Thanx for your help
-Doug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top