|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Cdo email not delivering the messages
Regarding this thread:http://forums.aspfree.com/microsoft-iis-12/smtp-server-problem-194417.html] , could somebody tell me if I should modify something to the component in order to work?
the whole code looks like this: Code:
Public ErrorStrMail As Variant
Dim oMail As CDO.Message
Dim oConf As CDO.Configuration
Dim FileSize
Dim SumSize
Dim oFlds
Dim oFSO
Dim oFile
Dim sFolder
Dim oFolder
Dim user
Private SMTPSrvr As String
Private SMTPPrt As Integer
Private Sndusing As Integer
Property Let SMTPServer(text As String)
SMTPSrvr = text
End Property
Property Let SMTPPort(valu As Integer)
SMTPPrt = valu
End Property
Property Let SendUsing(valu2 As Integer)
Sndusing = valu2
End Property
Public Function SendMail(toAddr, whoAddr, docSubj, docMsg, ByVal docType As Integer, Optional cc = "", Optional bcc = "", Optional sFolder = "", Optional user = "")
On Error GoTo MailErr
Set oFlds = oConf.Fields
oFlds(cdoSendUsingMethod) = Sndusing
oFlds(cdoSMTPServer) = SMTPSrvr
oFlds(cdoSMTPServerPort) = SMTPPrt
oFlds(cdoSMTPAuthenticate) = cdoBasic
oFlds.Update
Set oMail = New CDO.Message
oMail.From = whoAddr
oMail.To = toAddr
If (cc <> "") Then
oMail.cc = cc
If (bcc <> "") Then
oMail.bcc = bcc
If oFSO.FolderExists(sFolder) Then
Set oFolder = oFSO.GetFolder(sFolder)
For Each oFile In oFolder.Files
If InStr(oFile.Name, "_" & user) > 0 Then
oMail.AddAttachment oFile.Path
FileSize = Format((FileLen(oFile) / 1024) / 1024)
SumSize = SumSize + FileSize
oFSO.DeleteFile (oFile)
End If
Next
End If
End If
End If
If ((docType Mod 2) = 0) Then
oMail.TextBody = docMsg
Else:
oMail.HTMLBody = docMsg
End If
If (SumSize > 10) Then
ErrorStrMail = "Attachment size too large!"
GoTo MailFlee
End If
oMail.Subject = docSubj
Set oMail.Configuration = oConf
oMail.Send
MailFlee:
Exit Function
MailErr:
ErrorStrMail = Err.Number & ":" & Err.Description
Resume MailFlee
End Function
Private Sub Class_Initialize()
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oConf = New CDO.Configuration
Set oFlds = oConf.Fields
FileSize = 0
SumSize = 0
oFlds(cdoSendUsingMethod) = Sndusing
oFlds(cdoSMTPServer) = SMTPSrvr
oFlds(cdoSMTPServerPort) = SMTPPrt
oFlds(cdoSMTPAuthenticate) = cdoBasic
oFlds.Update
End Sub
Thanks in advance! |
|
#2
|
||||
|
||||
|
--moved to the VB forum.
regarding your question: yes, you have to define SMTPSrvr. currently in your code it's empty so it's obvious you'll get error. if the mail server is the same as the web server, give this "localhost" or "127.0.0.1" value. |
|
#3
|
||||
|
||||
|
Quote:
![]() Regarding the value of SMTPSrvr....that value and the SMTPPrt,and SndUsing are set in the asp page......the smtp server I'm using is a mail server...I dunno if I'm missing something here.... |
|
#4
|
||||
|
||||
|
Quote:
|
|
#5
|
||||
|
||||
|
the SMTP Server address I'm using is valid...
![]() |
|
#6
|
||||
|
||||
|
I'm being told that the following thing happens : the application tries to connect to the server , but the process is put on hold until it stops.Could this be related to the connection timeout (if it's not set,it could have a default value....)?
|
|
#7
|
||||
|
||||
|
this can be related to many things: network problems and permissions problems
are two common problems. |
|
#8
|
||||
|
||||
|
Dunno if this is somehow related to permissions....apparently the application is in the list of applications that are allowed to use the email server.....but if the component would be wrong developed,would it be possible to work from time to time?this is what bothers me....
|
|
#9
|
||||
|
||||
|
keep in mind that if you call this component from within ASP, you will
have very limited permissions of the IUSR account of the web server. |
|
#10
|
||||
|
||||
|
I tried sending an email from an asp page and it works....dunno what's wrong with the component....
![]() |
|
#11
|
||||
|
||||
|
probably some fancy code using something that needs permissions.
try to add Try..Catch blocks to the code to narrow the possibilities down. |
|
#12
|
||||
|