From: PAkerly on
I'm trying to send an email message to outside of my domain
recipients. I get a relay not allowed message. I need to
authenticate.

Can this be done with this code? FYI, emails are sent fine if sent
within mycompany.com domain

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
'
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Test email"
objMessage.From = "me(a)mycompany.com"
objMessage.To = "me(a)gmail.com"
objMessage.TextBody = "This is some sample message text"
For Each objFile In objFolder.Files
strFileExt = objFSO.GetExtensionName(objFile.Path)
objMessage.AddAttachment objFile.Path
Next
'Configuration Info
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"myserver.mycompany.com"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
From: Pegasus [MVP] on


"PAkerly" <pakerly(a)gmail.com> said this in news item
news:0bf01f85-a565-4680-87ef-a61b897fdb31(a)k9g2000vbl.googlegroups.com...
> I'm trying to send an email message to outside of my domain
> recipients. I get a relay not allowed message. I need to
> authenticate.
>
> Can this be done with this code? FYI, emails are sent fine if sent
> within mycompany.com domain
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFolder = objFSO.GetFolder(strFolder)
> '
> Set objMessage = CreateObject("CDO.Message")
> objMessage.Subject = "Test email"
> objMessage.From = "me(a)mycompany.com"
> objMessage.To = "me(a)gmail.com"
> objMessage.TextBody = "This is some sample message text"
> For Each objFile In objFolder.Files
> strFileExt = objFSO.GetExtensionName(objFile.Path)
> objMessage.AddAttachment objFile.Path
> Next
> 'Configuration Info
> objMessage.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
> 'Name or IP of Remote SMTP Server
> objMessage.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
> "myserver.mycompany.com"
> 'Server port (typically 25)
> objMessage.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
> 25
> objMessage.Configuration.Fields.Update
> '==End remote SMTP server configuration section==
> objMessage.Send

Here is how you could authenticate yourself to an external SMTP server:

const cdoBasic=1
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "James(a)company.com"
.To = "Jim(a)company.com"
.Subject = "Test Mail"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
.AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.company.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "James(a)company.com"
.Item (schema & "smtpaccountname") = "James(a)company.com"
.Item (schema & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With


 | 
Pages: 1
Prev: Domain Logonserver
Next: Advanced use of elevation