USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  ASP - Active Server Page    (Miscelâneas)

Título da Dica:  Função escolhe e-mail
Postada em 9/12/2003 por Mago_Pc            
Atravez de uma combo ou uma list box vc poderá passar o valor para a função.
Esta função é muito util para sistema de gerenciamento de e-mail , pq vc poderá escoler qual o componente vc vai usar para enviar e-mail.

<%
Function SendMail(strEmailBody, strEmailAddress, strSubject, strMailComponent)

     
     Dim objCDOSYSMail     'Objeto CDOSYS mail
     Dim objCDOMail          'Objeto CDONTS mail
     Dim objJMail          'Objeto Jmail
     Dim objAspEmail          'Objeto AspEmail
     Dim objAspMail          'Objeto AspMail

     
     Select Case strMailComponent
     
          'CASO CDOSYS
          Case "CDOSYS"
               
               
               Dim objCDOSYSCon
               

               Set objCDOSYSMail = Server.CreateObject("CDO.Message")
                   Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
                  
                  
    
                  objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
           
                  objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
                  
                  objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                  
                  objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
                  objCDOSYSCon.Fields.Update
          

               Set objCDOSYSMail.Configuration = objCDOSYSCon
               
               
               
               objCDOSYSMail.From = "<" & strEmailAddress & ">"
                              
               objCDOSYSMail.To = "<" & strEmailAddress & ">"
                                        
               
               objCDOSYSMail.Subject = strSubject
                              
               
               objCDOSYSMail.HTMLBody = strEmailBody
               
               
               If NOT strSMTPServer = "" Then objCDOSYSMail.Send                    
                                   

               Set objCDOSYSMail = Nothing
          
          'COSO CDONTS
          Case "CDONTS"
          
               
               Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
          

               objCDOMail.From = "<" & strEmailAddress & ">"
                              
               
               objCDOMail.To = "<" & strEmailAddress & ">"
                                        
               
               objCDOMail.Subject = strSubject
                              

               objCDOMail.Body = strEmailBody

               objCDOMail.BodyFormat = 0

               objCDOMail.MailFormat = 0

               objCDOMail.Importance = 1
                              

               objCDOMail.Send                    
                                   
               
               Set objCDOMail = Nothing
          
          
          'CASO JMAIL
          Case "Jmail"
     
               
               Set objJMail = Server.CreateObject("JMail.SMTPMail")

               objJMail.ServerAddress = strSMTPServer
          
               
               objJMail.Sender = strEmailAddress
                              
               
               objJMail.AddRecipient strEmailAddress
                                             

               objJMail.Subject = strSubject
                              
               
               objJMail.HTMLBody = strEmailBody
                              
     
               objJMail.Priority = 3
                              

               If NOT strSMTPServer = "" Then objJMail.Execute                    
                                   

               Set objJMail = Nothing
               
          
          Case "AspEmail"
     

               Set objAspEmail = Server.CreateObject("Persits.MailSender")
               

               objAspEmail.Host = strSMTPServer
                    
          
               objAspEmail.From = strEmailAddress
                    
               
               objAspEmail.AddAddress strEmailAddress
                                                            

               objAspEmail.Subject = strSubject
               

               objAspEmail.IsHTML = True
               

               objAspEmail.Body = strEmailBody
                                             
          
               If NOT strSMTPServer = "" Then objAspEmail.Send               
                              
               
               Set objAspEmail = Nothing
          

          Case "AspMail"
     

               Set objAspMail = Server.CreateObject("SMTPsvg.Mailer")
               
               objAspMail.RemoteHost = strSMTPServer
                    
          
               objAspMail.FromAddress = strEmailAddress
                    
               
               objAspMail.AddRecipient strEmailAddress
                                                            
               
               objAspMail.Subject = strSubject
               

               objAspMail.ContentType = "text/html"
               
               
               objAspMail.BodyText = strEmailBody
                                             

               If NOT strSMTPServer = "" Then objAspMail.SendMail                
                              
               
               Set objAspMail = Nothing
     End Select     
     
     
     SendMail = True
End Function
%>
 


CyberWEB Network Ltda.    © Copyright 2000-2018   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página