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

Corrupting attachments sent via CDO VBScript 1

Status
Not open for further replies.

TrevJones

Programmer
Nov 20, 2000
37
GB
Hi

I am having a problem with certain word documents I am sending via CDO message. Some attachments are ok but some cause problems when they are being opened in word. The original document is ok, it is just the attachment that is causing a problem.

The code i am using is

Set MyMail = CreateObject("CDO.Message")
Set cdoConfig = CreateObject("CDO.Configuration")
with cdoConfig.fields
.item(" = 2
end with
Set MyMail.Configuration = cdoConfig

MyMail.From = "WitsBaseVBmail"
MyMail.To = toAddr
MyMail.Subject = subject
MyMail.TextBody = body
'
WScript.Echo "--------------------------------------------------------------------------"
If WScript.Arguments.Count >3 Then
For Each sAttach In FileArray
MyMail.AddAttachment sAttach

If Err.Number = 0 Then
WScript.Echo "File " & sAttach & " has been attached to message"
Else
WScript.Echo "File " & sAttach & " has not been attached, err - " & Err.Number
End If
WScript.Echo "--------------------------------------------------------------------------"
'wscript.sleep 30000
Next
End If
'

MyMail.Send()


on a 2003 server. Any suggestions please?

Cheers
 
One thing to try is setting the Message object's [tt]MIMEFormatted[/tt] property to False (it should be defaulting to True).

Beyond this you may find you'll need to set the [tt]ContentMediaType[/tt] property on each Attachment object, probably to "application/msword" or something similar.


But that may be jumping to conclusions. It would help to know what is different about the distorted Word docs and in what way are they distorted.
 
Thank you very much, setting the MIMEFormatted property to False seems to have worked. It was hard to see what was wrong with the attachment as word just wouldn't open it and the actual file was ok.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top