LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Problems with sending eMail by SMTP

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




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending a Spreadsheet as an Email Attachment vs. Imbedded in Email billbrandi Excel Discussion (Misc queries) 1 April 3rd 08 03:44 AM
Email sending colourp Excel Discussion (Misc queries) 1 January 13th 06 01:13 AM
How 2 remove this error - SMTP Server, Email using CDO Yongjun CHEN Excel Programming 1 March 23rd 05 08:47 PM
Sending mail from Excel with CDO - return SMTP value Kent Excel Programming 1 February 22nd 05 04:03 PM
Sending an email Jamie Excel Programming 2 October 14th 04 02:51 PM


All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"