Name of the attachment gets added automatically to the body of the email

D

DPM

Hi,



I have noticed that the name of the attachment gets added into the body of
the email, eventhough not specified in the body of the email when composing
and sending an email using MSOutlook programmatically.



The email received in InBox,

- Has the actual attachment on top of the email as expected.

- Body gets the name of the attachment, eventhough the detail added to the
mail was only "This is a test email." as follows,

"T <<07.04.02 - PlanningPermit.pdf>> his is a test email."

"07.04.02 - PlanningPermit.pdf" is the name of the attachment

- This happens with MS OutLook 2003 SP3

- This program works fine with MSO 2003 SP2 on another computer.



Please could someone advice on how to get rid of the attachment name getting
added to the body of the email enclosed with << and >>.
 
D

DPM

Hi Sue,

loOutLookSession = CREATEOBJECT('OutLook.Application')
loOutBox = loOutLookSession.GetNameSpace("MAPI").GetDefaultFolder(4)
loMailItem = loOutBox.Items.Add(0)

loMailItem.Subject = "This is the Subject"
loMailItem.BodyFormat = 1
loMailItem.Body = "This is the Detail"
loMailItem.TO = <To recipient>

lcAttachment = <Name of the attachment>
lnAttachmentPosition = loMailItem.Attachments.Count + 1
loMailItem.Attachments.Add(lcAttachment, 1, lnAttachmentPosition, <Display
name of the attachment>)

loMailItem.Send()
 
S

Sue Mosher [MVP-Outlook]

Try changing your Attachments.Add statement to:

loMailItem.Attachments.Add(lcAttachment, 1)

Neither the position nor the display name parameters are relevant to a plain
text message with the file attached by value.

You might also try setting Body after you attach the file.
 
D

DPM

Hi Sue,

Thanks, I'll try to see if it works.


Sue Mosher said:
Try changing your Attachments.Add statement to:

loMailItem.Attachments.Add(lcAttachment, 1)

Neither the position nor the display name parameters are relevant to a
plain
text message with the file attached by value.

You might also try setting Body after you attach the file.
 
D

DPM

Hi Sue,

Thanks it works.
For this we did not set the index possition of the attachments when the mail
is sent in plain text.
 

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