Jump to content


Photo

Anexo No E-mail


  • Faça o login para participar
6 replies to this topic

#1 PriLima

PriLima

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Feminino

Posted 04/05/2007, 14:26

criei o código para anexar os arquivos ao e-mail, mas ele está tentando anexar um arquivo do servidor.
Não sei o que eu faço para arrumar isso. :(



Var_Anexo = Request.Form("anexo")



Obj_Email.AddAttachment (Var_Anexo)

#2 ellen

ellen

    Novato no fórum

  • Usuários
  • 17 posts
  • Sexo:Não informado

Posted 04/05/2007, 14:40

Oi Pri....

Qual componente vc está usando para o envio de email e para o upload??

#3 PriLima

PriLima

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Feminino

Posted 04/05/2007, 14:55

Como?

Seria essa a resposta???
Obj_Email = Server.CreateObject("CDO.Message")

#4 ellen

ellen

    Novato no fórum

  • Usuários
  • 17 posts
  • Sexo:Não informado

Posted 04/05/2007, 15:07

Eu tenho um código q funciona perfeitamente, mas tá em CDOsys e SaFileUp.. te ajuda?



Dê uma olhada aki tbem...
http://site.locaweb....q...733&faq=935

Edição feita por: ellen, 04/05/2007, 15:14.


#5 PriLima

PriLima

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Feminino

Posted 04/05/2007, 15:21

em CDOsys sim.

Pode mandar?

#6 ellen

ellen

    Novato no fórum

  • Usuários
  • 17 posts
  • Sexo:Não informado

Posted 04/05/2007, 17:09

Olha meu código...

<%

flag = request("flag")
if flag = "" then
flag = 0
end if

function trata_string(str)
str = replace(str,vbCrLf,"<br />")
trata_string = str
end function

if flag then
On Error Resume Next
nome = Request.Form("nome")
telefone = Request.Form("telefone")
email = Request.Form("email")
cidade = Request.Form("cidade")
estado = Request.Form("estado")
mensagem = Request.Form("mensagem")


if email = "" then
email = "seu email"
end if

'Coloque aqui o titulo
titulo = "Contato "
enviou = 0 'nada
e_mail = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR...nal.dtd""><html xmlns=""http://www.w3.org/19...l""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" /></head><body>"
e_mail = e_mail &"<font face=""Arial"" size=""2""><h5>" & titulo & " - " & now & "</h5>"
e_mail = e_mail & "<b>Nome: </b> " & nome & " <br>"
e_mail = e_mail & "<b>Telefone:</b> " & telefone & " <br>"
e_mail = e_mail & "<b>E-mail:</b> " & email &" <br>"
e_mail = e_mail & "<b>Cidade/Estado:</b> " & cidade &"/"& estado &" <br>"
e_mail = e_mail & "<b>Mensagem: </b> " & "<br>"
e_mail = e_mail & mensagem & " <br>"
e_mail = e_mail & "____________________________________________________________________________" & "</font><br>"
e_mail = e_mail & "</body></html>"
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
With objCDOSYSCon
.Fields("http://schemas.micro...ion/smtpserver") = "localhost"
.Fields("http://schemas.micro...smtpserverport") = 25
.Fields("http://schemas.micro...tion/sendusing") = 2
.Fields("http://schemas.micro...nectiontimeout") = 30
.Fields.update
End With
Set objCDOSYSMail.Configuration = objCDOSYSCon
With objCDOSYSMail
.From = email
.To = "seu email"
if session("arquivo") <> "" then
.AddAttachment(Session("Arquivo"))
end if
.Subject = titulo
.HtmlBody = trata_string(e_mail)
.Send
if acao = "upload" then
Session("Arquivo") = ""
end if
End With
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Set obj_Upload = Nothing
msg = "Contato enviado com sucesso" ' certo
Session("Arquivo") = ""


If Err.number<>0 then
msg = "Ocorreu um erro ao enviar o contato." 'errado
End If
end if




acao = request("acao")
if acao = "" then
acao = "none"
end if

if acao = "upload" then 'caso a acao seja upload, executa script do SaFileUp
Set obj_Upload = Server.CreateObject("SoftArtisans.FileUp")
obj_Upload.Path = Server.MapPath("./upload") 'local onde será gravado o arquivo
if obj_Upload.TotalBytes > 1000000 then
Response.Write "<script>alert('Seu arquivo ultrapassou o limite de 1MB.')</script>"
v_foco = " onLoad=""document.contato.nome.focus();"""
session("arquivo") = ""
else
on error resume next
obj_Upload.Form("File").Save
Session("arquivo") = obj_Upload.Form("File").ServerName 'recupera o nome do arquivo no servidor
if err.number<>0 then
Response.Write "<script>alert('Você deve selecionar um arquivo antes de anexar.')</script>"
session("arquivo") = ""
else
Response.Write "<script>alert('Seu arquivo foi anexado. Por favor, agora preencha o formulário com seus dados!')</script>"
v_foco = " onLoad=""document.contato.nome.focus();""" 'coloca o cursor no campo do form de nome
end if
' Session("Arquivo") = ""
end if
End if

%>


Qualquer dúvida... me avise...

#7 PriLima

PriLima

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Feminino

Posted 08/05/2007, 10:45

Obrigasa Ellen, vou tentar fazer.


Olha meu código...

<%

flag = request("flag")
if flag = "" then
flag = 0
end if

function trata_string(str)
str = replace(str,vbCrLf,"<br />")
trata_string = str
end function

if flag then
On Error Resume Next
nome = Request.Form("nome")
telefone = Request.Form("telefone")
email = Request.Form("email")
cidade = Request.Form("cidade")
estado = Request.Form("estado")
mensagem = Request.Form("mensagem")


if email = "" then
email = "seu email"
end if

'Coloque aqui o titulo
titulo = "Contato "
enviou = 0 'nada
e_mail = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR...nal.dtd""><html xmlns=""http://www.w3.org/19...l""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" /></head><body>"
e_mail = e_mail &"<font face=""Arial"" size=""2""><h5>" & titulo & " - " & now & "</h5>"
e_mail = e_mail & "<b>Nome: </b> " & nome & " <br>"
e_mail = e_mail & "<b>Telefone:</b> " & telefone & " <br>"
e_mail = e_mail & "<b>E-mail:</b> " & email &" <br>"
e_mail = e_mail & "<b>Cidade/Estado:</b> " & cidade &"/"& estado &" <br>"
e_mail = e_mail & "<b>Mensagem: </b> " & "<br>"
e_mail = e_mail & mensagem & " <br>"
e_mail = e_mail & "____________________________________________________________________________" & "</font><br>"
e_mail = e_mail & "</body></html>"
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
With objCDOSYSCon
.Fields("http://schemas.micro...ion/smtpserver") = "localhost"
.Fields("http://schemas.micro...smtpserverport") = 25
.Fields("http://schemas.micro...tion/sendusing") = 2
.Fields("http://schemas.micro...nectiontimeout") = 30
.Fields.update
End With
Set objCDOSYSMail.Configuration = objCDOSYSCon
With objCDOSYSMail
.From = email
.To = "seu email"
if session("arquivo") <> "" then
.AddAttachment(Session("Arquivo"))
end if
.Subject = titulo
.HtmlBody = trata_string(e_mail)
.Send
if acao = "upload" then
Session("Arquivo") = ""
end if
End With
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Set obj_Upload = Nothing
msg = "Contato enviado com sucesso" ' certo
Session("Arquivo") = ""


If Err.number<>0 then
msg = "Ocorreu um erro ao enviar o contato." 'errado
End If
end if




acao = request("acao")
if acao = "" then
acao = "none"
end if

if acao = "upload" then 'caso a acao seja upload, executa script do SaFileUp
Set obj_Upload = Server.CreateObject("SoftArtisans.FileUp")
obj_Upload.Path = Server.MapPath("./upload") 'local onde será gravado o arquivo
if obj_Upload.TotalBytes > 1000000 then
Response.Write "&lt;script>alert('Seu arquivo ultrapassou o limite de 1MB.')</script>"
v_foco = " onLoad=""document.contato.nome.focus();"""
session("arquivo") = ""
else
on error resume next
obj_Upload.Form("File").Save
Session("arquivo") = obj_Upload.Form("File").ServerName 'recupera o nome do arquivo no servidor
if err.number<>0 then
Response.Write "&lt;script>alert('Você deve selecionar um arquivo antes de anexar.')</script>"
session("arquivo") = ""
else
Response.Write "&lt;script>alert('Seu arquivo foi anexado. Por favor, agora preencha o formulário com seus dados!')</script>"
v_foco = " onLoad=""document.contato.nome.focus();""" 'coloca o cursor no campo do form de nome
end if
' Session("Arquivo") = ""
end if
End if

%>


Qualquer dúvida... me avise...






1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq