Problems with mail attachments
Hi!
I have problems with attachmnets, when I send mail from my application. Here is the code:
Dim mySmartUpload
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
mySmartUpload.Upload
Set fs = CreateObject("Scripting.FileSystemObject")
Set posta = Server.CreateObject("jmail.smtpmail")
posta.ServerAddress = "xxx.xxx.x.xxx:xx"
posta.Silent = True
posta.AddRecipient Data("email")'I get data from database
Data.MoveNext
Loop
posta.Sender = "john.doe@mail.com"
posta.SenderName = "Sender"
posta.Subject = "Subject"
posta.Charset ="Windows-1250"
posta.ContentType = "text/html"
posta.ISOEncodeHeaders = False
posta.Body = "<b>" & title & "</b><br><br>" & content 'get that from from
'''''''''''''''''''' attachment ''''''''''''''''''''''
If mySmartUpload.files.item(1).filename <> "" Then
path = "d:\...\...\"
'HERE I CREATE A FILE AND PUT IN ON THE SERVER. SO I ATTACH TO THE MAIL FILE FROM THAT FOLDER ON THE SERVER. BEFORE I SAVE THE FILE I HAVE TO "CLEAN" IT OF ALL CHARACHTERS THAT COULD CAUSE PROBLEMS.
datotekaIme = Left(mySmartUpload.files.item(1).filename, Len(mySmartUpload.files.item(1).filename) - Len(mySmartUpload.files.item(1).fileext) - 1)
datotekaKoncnica = mySmartUpload.files.item(1).fileext
datotekaIme = Replace(datotekaIme, " ", "")
datotekaIme = Replace(datotekaIme," ","_")
datotekaIme = Replace(datotekaIme,"..",".")
datotekaIme = Replace(datotekaIme,"...",".")
datotekaIme = Replace(datotekaIme,"(","_")
datotekaIme = Replace(datotekaIme,")","_")
datotekaIme = Replace(datotekaIme,"Å ","S")
datotekaIme = Replace(datotekaIme,"Å¡","s")
datotekaIme = Replace(datotekaIme,"Ã","C")
datotekaIme = Replace(datotekaIme,"è","c")
datotekaIme = Replace(datotekaIme,"Ã","C")
datotekaIme = Replace(datotekaIme,"æ","c")
datotekaIme = Replace(datotekaIme,"Ž","Z")
datotekaIme = Replace(datotekaIme,"ž","z")
datotekaKoncnica = Replace(datotekaKoncnica, " ", "")
if (len(datotekaIme) > 40) then datotekaime = left(datotekaime, 40)
datoteka = datotekaIme & "." & datotekaKoncnica
Do While fs.FileExists(pot & datoteka)
datotekaIme = datotekaIme & "_new"
datoteka = datotekaIme & "." & datotekaKoncnica
Loop
mySmartUpload.files.item(1).saveAs(path & datoteka)
posta.AddAttachment path & datoteka
End If
'''''''''''''''''''' attachment ''''''''''''''''''''''
posta.Execute()
set posta=Nothing
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
The problem is that the user gets the attachment, but it has wrong format. For example: if i send some Word document let's say invitation.doc, the user gets file invitation.doc.dat And i don't now why.
Anyone?
Thanks in advance!
|