View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
PaulC PaulC is offline
external usenet poster
 
Posts: 1
Default Sending email from Excel vba problem


Ron

I have just got back to this problem, and have been trying your
suggestion of using CDO.

I am working on a LAN and want everyone to be able to use the resulting
code to be able to send attachements from the Excel file back to one of
the users. We use Outlook and don't have Outlook Express set up for
users.

I started with the following code:

Sub CDO_Send_Workbook()
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant


Application.ScreenUpdating = False


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


iConf.Load -1 ' CDO Source Defaults

Set Flds = iConf.Fields
With Flds


..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2


..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"our proxy server"


..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25


..Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
"domain\username"


..Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
"password"

..Update

End With


With iMsg
Set .Configuration = iConf
..To = "admin user email"
..From = """paul"" <my email"
..Subject = "Your Weekly Performance Files"
..TextBody = "Weekly Files"
..AddAttachment "U:\Temp\Time.xls"
..Send
End With


Set iMsg = Nothing
Set iConf = Nothing
Set wb = Nothing
Application.ScreenUpdating = True

End Sub


I put in the full domain name, and my usersname, but not sure about the
password (used my usual logon password).

It returns a run time error: "The message could not be sent to the SMTP
server. The transport error code was 0x800cc15. The server response was
not available."

I realise I am a bit out of my depth, but if there is a something
obvious I am doing wrong...

Thanks in anticipation,

Paul


--
PaulC
------------------------------------------------------------------------
PaulC's Profile: http://www.excelforum.com/member.php...fo&userid=7563
View this thread: http://www.excelforum.com/showthread...hreadid=380386