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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS .AttachFile is swapping with .Body!!!

Status
Not open for further replies.

ChainsawJoe

Programmer
Dec 5, 2000
154
GB
G'morning all.

This one is really confusing me; I'm using CDONTS NewMail to send an email having attached a file using the .AttachFile method. If I

[ol]
[li]Attach no file - the email recieved is fine and dandy[/li]
[li]Attach two files - the email is great. With both attachments as should be.[/li]
[li]Attach one file - the .Body is attached and the .AttachFile becomes the .Body[/li][/ol]

Does that make sense? If I attach one file, the resulting email has the specified body as the attachment and the attachment is shown as the email body! To make it "work" I could either comment out the .AttachFile or copy and paste it again below - these work fine.

Has anyone else had this problem? Could it be a dodgy CDONTS that I should get my host to reinstall?

Here's a section of the function I use;
Code:
sub subSendEmail(sEmailTemplateFile, sAttachFileName, iUserID)
	'-- declare vars
	dim oMail, sEmailBody
	Set oMail = CreateObject("CDONTS.NewMail")
		
	'-- get email body
	sEmailBody	= fnReadFile(sEmailTemplateFile)
		
	'-- do email stuff
	with oMail
		'-- build headers
		.From		= "me@here.com"
		.To		= "you@there.com"
		.Bcc		= "me2@here.com"
		.Subject	= "This is a Test"
		.Body		= sEmailBody
			    
		 '-- attach index.htm
		.AttachFile (Server.MapPath(sAttachFileName),"index.htm")
			
		'-- send the email
		.Send
	end with
		
	'-- stoppit and tidyup
	set oMail	= nothing
end sub

arigato gozaimasu, everybody.

Joe --------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top