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

Send mails in HMTL Format

Status
Not open for further replies.

aspmonster

IS-IT--Management
Dec 11, 2003
25
US
I have this code which I been using to send mails in simple Notepad style format. But I would like to send mails in HMTL format adding table format and font style.
I also use an upload object to attach and send document. Any help in this would be great.
Here is my code
=====================================================

<%
Response.Buffer = true
Function BuildUpload(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString(&quot;--&quot;)))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject(&quot;Scripting.Dictionary&quot;)
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString(&quot;Content-Disposition&quot;))
Pos = InstrB(Pos,RequestBin,getByteString(&quot;name=&quot;))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString(&quot;filename=&quot;))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add &quot;FileName&quot;, FileName
Pos = InstrB(PosEnd,RequestBin,getByteString(&quot;Content-Type:&quot;))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add &quot;ContentType&quot;,ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add &quot;Value&quot; , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Function

Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

Function getString(StringBin)
getString =&quot;&quot;
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function



If request(&quot;Action&quot;)=&quot;1&quot; then
Response.Clear
byteCount = Request.TotalBytes

RequestBin = Request.BinaryRead(byteCount)

Set UploadRequest = CreateObject(&quot;Scripting.Dictionary&quot;)

BuildUpload(RequestBin)

If UploadRequest.Item(&quot;blob&quot;).Item(&quot;Value&quot;) <> &quot;&quot; Then

contentType = UploadRequest.Item(&quot;blob&quot;).Item(&quot;ContentType&quot;)
filepathname = UploadRequest.Item(&quot;blob&quot;).Item(&quot;FileName&quot;)
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,&quot;\&quot;))
FolderName = UploadRequest.Item(&quot;where&quot;).Item(&quot;Value&quot;)
'Response.Write &quot;FolderName: &quot; & FolderName & &quot;<BR>&quot;
Path = Mid(Request.ServerVariables(&quot;PATH_TRANSLATED&quot;), 1, Len(Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)) - Len(Request.ServerVariables(&quot;PATH_INFO&quot;))) & &quot;\&quot;
'Response.Write &quot;Path:&quot; & Path & &quot;<BR>&quot;
ToFolder = Path & &quot;\&quot; & FolderName
value = UploadRequest.Item(&quot;blob&quot;).Item(&quot;Value&quot;)
filename = ToFolder & &quot;\&quot; & filename
Set MyFileObject = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = MyFileObject.CreateTextFile(filename)
'Response.Write &quot;Saved Path: &quot; & filename
For i = 1 to LenB(value)
objFile.Write chr(AscB(MidB(value,i,1)))
Next
objFile.Close
Set objFile = Nothing
Set MyFileObject = Nothing
End If

Dim MyTo
Dim MySubject

' get the other form elements now
'MySubject = UploadRequest.Item &quot;Hotline Form.&quot;
'MyTo = UploadRequest.Item &quot;holdae@hotmail.com&quot;

Dim StrMailBody
StrMailBody = &quot;To Customer Support/Training,&quot; & _
&quot;<br>&quot; & &quot; I manned the Customer Care Training Hotline today, please find the Hotline support report below &quot; & _
&quot;<br>&quot; & _
&quot;<br>&quot; & &quot;<b>Date Submitted: </b>&quot; & UploadRequest.Item(&quot;Expiration_date&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Time Called: </b>&quot; & UploadRequest.Item(&quot;hour1&quot;).Item(&quot;Value&quot;) & &quot;:&quot; & UploadRequest.Item(&quot;minute1&quot;).Item(&quot;Value&quot;) & UploadRequest.Item(&quot;time1&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Type of Call: </b>&quot; & UploadRequest.Item(&quot;callname&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Caller's First Name: </b>&quot; & UploadRequest.Item(&quot;nomcomp&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Caller's Last Name: </b>&quot; & UploadRequest.Item(&quot;nomcomp1&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Caller's Team Name: </b>&quot; & UploadRequest.Item(&quot;team&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Other(Team Name): </b>&quot; & UploadRequest.Item(&quot;teamname&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Account Number: </b>&quot; & UploadRequest.Item(&quot;accnumber&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Caller Question: </b>&quot; & UploadRequest.Item(&quot;msg&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Caller Answer: </b>&quot; & UploadRequest.Item(&quot;msg1&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Date Resolved: </b>&quot; & UploadRequest.Item(&quot;Expiration_date1&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Time Resolved: </b>&quot; & UploadRequest.Item(&quot;hour2&quot;).Item(&quot;Value&quot;) & &quot;:&quot; & UploadRequest.Item(&quot;minute2&quot;).Item(&quot;Value&quot;) & UploadRequest.Item(&quot;sec2&quot;).Item(&quot;Value&quot;) &_
&quot;<br>&quot; & &quot;<b>Trainer's Name: </b>&quot; & UploadRequest.Item(&quot;trainname&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>Assisted By: </b>&quot; & UploadRequest.Item(&quot;trainassit&quot;).Item(&quot;Value&quot;) & _
&quot;<br>&quot; & &quot;<b>For more information about our Hotline Policy.</b>&quot;


Set UploadRequest = Nothing
Set objCDOMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
ObjCDOMail.From = &quot;chingy@chotmail.com&quot;
ObjCDOMail.To = &quot;chingy@chotmail.com&quot;
'ObjCDOMail.To = &quot;holidaeinn@chotmail.com&quot;
ObjCDOMail.BodyFormat = 0
ObjCDOmail.Mailformat = 0
ObjCDOMail.Subject = &quot;Hotline Feedback&quot;
ObjCDOMail.Body = StrMailBody
'heres an if statement to check for an attachment

If Len(filename) > 5 then
objCDOMail.AttachFile filename,nikfile
end if
ObjCDOMail.Send
Set ObjCDOMail = Nothing
End If
%>

=====================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top