2010-02-09 4 views
0

나는 이것을 시도 :VB 코드 페이지에서 asp를 사용하여 이메일을 보내는 방법은 무엇입니까?

  Dim mail 
     mail = Server.CreateObject("CDO.Message") 
     mail.To = consul.Email 
     mail.From = "[email protected]" 
     mail.Subject = subj 
     mail.HTMLBody = Bdy 
     mail.Send() 
     mail = Nothing 

그것은 내게 다음과 같은 오류를 준 : "SendUsing"구성 값이 잘못되었습니다.

+0

당신은 태그 그것을 asp.net/vb.net하지만 게시 된 코드가 ASP/VBScript를합니다. –

답변

0

이것은 내 응용 프로그램에 사용하는 코드이며 ASP.NET 용입니다. .net.mail에 대한 클래스 상단에서 가져 오기를 수행해야합니다. -> 수입 System.Net.Mail


Public Sub SendEmail(ByVal Sentfrom As String, ByVal Recipient As String, _ ByVal SubjectLine As String, ByVal Messagebody As String)

Dim SmtpEngine As New SmtpClient SmtpEngine.Host = "yourhost.com" Try SmtpEngine.Send(Sentfrom & "@taco.com", Recipient & "@taco.com", SubjectLine, Messagebody) Catch ex As Exception My.Application.Log.WriteException(ex) End Try End Sub

0

이 기능을 시도해보십시오

Public Sub SendMsg(from, dest, subj, body) 
    Dim msg, flds, conf 

    Set msg = CreateObject("CDO.Message") 
    Set conf = CreateObject("CDO.Configuration") 
    Set flds = conf.Fields 

    flds(cdoSendUsingMethod) = cdoSendUsingPort 
    flds(cdoSMTPServer) = "smtp.xyz.org" 
    flds(cdoSMTPServerPort) = 25 

'if use SMTP authentication... 
     flds(cdoSMTPAuthenticate) = cdoBasic 
     flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxx" 
     flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "zzzzzz" 
    '... or, without SMTP authentication 
     flds(cdoSMTPAuthenticate) = cdoAnonymous 

    flds.Update 

    On Error Resume Next 
    With msg 
     Set .Configuration = conf 
     .BodyPart.CharSet = "utf-8" 
     .TextBodyPart.CharSet = "utf-8" 
     .To = dest 
     .From = from 
     .Subject = subj 
     .TextBody = body 
     .Send 
    End With 
    On Error Goto 0 

    set msg = nothing 
    set conf = nothing 
    set flds = nothing 
End Sub 
관련 문제