Hallo,

I've written a procedure that automatically sends email with Outlook and
SMTP. I like the last one because there are no virus-alerts. Everything
works fine, but not in a network-situation (server with wireless
modem/router). By Outlook, everything works.

1. MAIL_Connected givesFALSE (however, I am on line)

2. I guess the fault is (see further for the whole code)

Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
gMXSMTP
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25

I guess the fault is smtpserverport = 25 becaus with eMail.Send
the procedure stops (gMXSMTP is correct setting for the SMTP-server)

Here is my code. The port for smtp is 25 (setting in outlook)

Dank
Jos

Public Declare Function InternetGetConnectedState Lib "wininet.dll"
(lpdwFlags As Long, ByVal dwReserved As Long) As Boolean

Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long,
lpExitCode As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long,
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103

Dim vRecipients As String, vFrom As String, vSubject As String, vBody As
String, vAttachment As String

Function MAIL_Connected() As Boolean

Dim Stat As Long

MAIL_Connected = (InternetGetConnectedState(Stat, 0&) <> 0)

End Function

Function MAIL_SMTP()

' This example use late binding, you don't have to set a reference
' You must be online when you run the sub

Dim eMail As Object
Dim iConf As Object
Dim wb As Workbook
Dim WBname As String

' Dim Flds As Variant

DISPLAY_Off

Set eMail = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

'Als SMPT niet ingesteld is (via een e-mail programma, moet deze code worden
ingesteld met de correcte SMTP-server
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields

Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
gMXSMTP
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25

Flds.Update

Set eMail.Configuration = iConf

eMail.To = vRecipients
eMail.CC = ""
eMail.BCC = ""
eMail.From = vFrom
eMail.Subject = vSubject
eMail.TextBody = vBody
eMail.AddAttachment vAttachment

eMail.Send

Set eMail = Nothing
Set iConf = Nothing
Set wb = Nothing

DISPLAY_On

End Function