ارسال ايميل با attachment

rezsat

Member
سلام.من قبلا با استفاده از اين كد ميتونم ايميل بفرستم.البته تا به حال فايلي ضميمه نكرده بودم و خط مربوط به اين امر هم (منظورم خط 10 ) غير فعال بود حالا ميخوام حتما فايلي رو هم بهش attach كنم.اگه ميشه اين كار ايا همين شكل زير درسته ؟ايا ميشه چند تا فايل رو هم بهش چسبند.چطوري؟
کد:
	Set Mail = Server.CreateObject("Persits.MailSender") 
	'Mail.Host = "smtp.smtp-server.com" ' Specify a valid SMTP server
	Mail.Host = "127.0.0.1" ' Specify a valid SMTP server
	Mail.From = "[email protected]" ' Specify sender's address
	Mail.FromName = "Test" ' Specify sender's name 
	
	Mail.AddAddress [email protected], "Andrew Johnson, Jr."
	'Mail.AddAddress "[email protected]", "Andrew Johnson, Jr."
	'Mail.AddAddress "[email protected]" ' Name is optional
	'Mail.AddReplyTo "[email protected]"
	Mail.AddAttachment "c:\images\cakes.gif" 
	
	Mail.Subject = "Test"
	Mail.Body = "Thank you" 
	
	'On Error Resume Next
	Mail.Send
	If Err <> 0 Then
	   Response.Write "Error encountered: " & Err.Description
	End If
	
	'To use  aspmail.please replace mail.domain with 127.0.0.1 in this
	'line:
	
	'mail1.host="mail.domain"
 
آخرین ویرایش:

rezsat

Member
حالا اميدوارم منظورمو واضح گفته باشم.ممنون ميشم كمك كنيد
 

rezsat

Member
ميشه بگيد چرا وقتي ايميل ارسال ميشه به جاي حرف فارسي ؟؟؟؟ نشون ميده.اينم كدهاي استفاده شده
کد:
<% session.codepage=65001 %>

<fieldset style="padding: 2; font-family:Tahoma; font-size:10pt">
	<legend align="center">لطفا تمام اطلاعات خواسته شده را به دقت پر نمائيد</legend>
&nbsp;<form method="POST" action="SendEmailBase.asp" name="send1" onSubmit="return checkFields1();">
		<div align="center">
			<table border="0" width="65%" id="table2" cellspacing="0">
				<tr>
					<td align="left" width="25%">نام فرستنده :</td>
					<td align="right" width="60%">
						<input type="text" name="FName" size="30" onkeypress="FKeyPress(send1);" onkeydown="FKeyDown(send1);">
						<font color="#FF0000">*</font>
					</td>
					<td width="15%">
						<img border="0" src="http://forum.majidonline.com/images/fa-en.gif" width="82" height="16" onclick="change(FName)" style="CURSOR: hand">
					</td>
				</tr>
				<tr>
					<td align="left" width="25%">نام گيرنده :</td>
					<td align="right" width="60%">
						<input type="text" name="TName" size="30" onkeypress="FKeyPress(send1);" onkeydown="FKeyDown(send1);">
						<font color="#FF0000">*</font></td>
					<td width="15%">
					<img border="0" src="http://forum.majidonline.com/images/fa-en.gif" width="82" height="16" onclick="change(TName)" style="CURSOR: hand"></td>
				</tr>
				<tr>
					<td align="left" width="25%">آدرس ايميل <span lang="fa">فرستنده</span> :</td>
					<td align="right" width="60%">
						<input type="text" name="SEmailAdd" size="30" dir="ltr" value="[email protected]"></td>
					<td width="15%">&nbsp;</td>
				</tr>
				<tr>
					<td align="left" width="25%">آدرس ايميل <span lang="fa">گيرنده</span> :</td>
					<td align="right" width="60%">
						<input type="text" name="REmailAdd" size="30" dir="ltr" value="[email protected]"><font color="#FF0000"> *</font></td>
					<td width="15%">
						&nbsp;</td>
				</tr>
				<tr>
					<td align="left" width="25%">موضوع :</td>
					<td align="right" width="60%">
						<input type="text" name="Sub" size="39" onkeypress="FKeyPress(send1);" onkeydown="FKeyDown(send1);">
						<font color="#FF0000">*</font></td>
					<td width="15%">
						<img border="0" src="http://forum.majidonline.com/images/fa-en.gif" width="82" height="16" onclick="change(Sub)" style="CURSOR: hand">
					</td>
				</tr>
				<tr>
					<td align="left" width="25%">توضيحات :</td>
					<td align="right" width="60%">
						<textarea rows="4" name="Desc" cols="40" onkeypress="FKeyPress(send1);" onkeydown="FKeyDown(send1);"></textarea>
						<font color="#FF0000">*</font>
					</td>
					<td width="15%">
						<img border="0" src="http://forum.majidonline.com/images/fa-en.gif" width="82" height="16" onclick="change(Desc)" style="CURSOR: hand">
					</td>
				</tr>
				<tr>
					<td align="left" width="100%" colspan="3"><hr></td>
				</tr>
				<tr>
					<td align="left" width="25%"><span lang="fa">فايل ضميمه :</span></td>
					<td align="right" width="60%">
						<p>
						<input name="upload_1" tabindex="7" type="file" onchange="preview(this)" size="55" class="fixed" dir="ltr"/>
						<input name="upload_2" tabindex="8" type="file" onchange="preview(this)" size="55" class="fixed" dir="ltr"/>
						<input name="upload_3" tabindex="9" type="file" onchange="preview(this)" size="55" class="fixed" dir="ltr"/>
						</p>
					</td>
					<td width="15%">
					<p align="center">
					<img alt="پيش نمايش" id="previewField" style="border:1px solid #FF0000; font-family: Tahoma; font-size: 10pt"></td>
				</tr>
				<tr>
					<td align="left" width="25%">&nbsp;</td>
					<td align="right" width="60%">&nbsp;</td>
					<td width="15%">&nbsp;</td>
				</tr>
			</table>
		</div>
		<p align="center">
		<input type="submit" value="تائيد و ارسال" name="Submit">&nbsp;
		<input type="reset" value="  بازنويسي  " name="Reset"></p>
		<input type="hidden" name="SDate" value="<%DisplayNormalDate()%>">
	</form>
	<p>&nbsp;</p>
</fieldset>

و

کد:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Send Email</title>
</head>
<body>

<%
session.codepage=65001

p_fname = Request.Form("FName")
p_tname = Request.Form("TName")
p_semail = Request.Form("SEmailAdd")
p_remail = Request.Form("REmailAdd")
p_sub = Request.Form("Sub")
p_desc = Request.Form("Desc")
p_up1 = Request.Form("upload_1")
p_up2 = Request.Form("upload_2")
p_up3 = Request.Form("upload_3")
p_date = Request.Form("SDate")

'session.codepage=65001

Set Mail = Server.CreateObject("Persits.MailSender") 
Mail.Host = "127.0.0.1" ' Specify a valid SMTP server

Mail.From = ""& p_semail &"" ' like [email protected]
Mail.FromName = ""& p_fname &"" ' Specify sender's name 


Mail.AddAddress ""& p_remail &"" 
'Mail.AddCC "[email protected]" 

'if p_up1 = "" then

'Mail.AddAttachment "e:\html\domains\yourdomaincom\html\filename.htm"
'Mail.AddAttachment ""& p_up1 &"" 
'Mail.AddAttachment ""& p_up2 &""
'Mail.AddAttachment ""& p_up3 &""


Mail.Subject = ""& p_sub &""

'Mail.Body = "فرستنده :"
'Mail.Body = ""& p_fname &"" & "<br>"
'Mail.Body = "تاريخ ارسال :"
'Mail.Body = ""& p_date &"" & "<br>"
'Mail.Body = "شرح :"
'Mail.Body = ""& p_desc &""
Mail.Body = ""& p_desc &"" + "[" + ""& p_date &"" + "]"

On Error Resume Next
Mail.Send

If Err <> 0 Then
   Response.Write "Error encountered: " & Err.Description
End If

Mail.SendToQueue 
Set Mail = Nothing

'response.write(p_fname) & "<br>"
'response.write(p_tname) & "<br>"
'response.write(p_semail) & "<br>"
'response.write(p_remail) & "<br>"
'response.write(p_sub) & "<br>"
'response.write(p_desc) & "<br>"
'response.write(p_up1) & "<br>"
'response.write(p_up2) & "<br>"
'response.write(p_up3) & "<br>"
'response.write(p_date)

response.redirect("SendEmail.asp")
%>

</body>
</html>
 
آخرین ویرایش:

ranjbar_2

Member
راهنمايي

اين سورس رو كه مي ذارم براي سايت خودت تغيير بده

در ضمن منم مشكل اتچ داشتم اگه حل شد بهم خبر بده
* راستي من با aspupload تونستم مشكل اتچ رو حل كنم ولي روي هيچ سروري نصب نيست كه بشه استفاده كرد

موفق و پيروز باشيد

<%
Session.CodePage = 65001 ' UTF-8 code
If Request("submit") <> "" Then
strHost = "dogonbad.com"
bo=" &nbsp;"& Request("body") &"&nbsp;&nbsp;"
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = strHost
mail.ishtml=true
Mail.CharSet = "UTF-8"
Mail.ContentTransferEncoding = "Quoted-Printable"
Mail.From =Request("from")
Mail.FromName =Request("from")
Mail.AddAddress Request("sendto")
Mail.Subject =Request("sub")
Mail.Body =bo
Mail.Send
if Request("sendto")="[email protected]" then
response.Redirect("default.asp")
else
response.Redirect("abmain.asp")
end if
End If
%>
 

جدیدترین ارسال ها

بالا