| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| I'm trying to send an email from an Access procedure using CDO. I've been able to do it successfully with three different sending email addresses, but not with the email address I actually need to use in production. In that case I get a message saying "The transport failed to connect to the server." I've tried several different ports. Anybody have any idea what the problem might be? My code is below. ----------------------------------------------------------------------------------------- Public Sub SendEmail() Dim imsg As Message Dim iconf As Object Dim flds As Object Dim schema As String Set imsg = CreateObject("CDO.Message") Set iconf = CreateObject("CDO.Configuration") Set flds = iconf.Fields ' send one copy with SMTP server (with autentication) schema = "http://schemas.microsoft.com/cdo/configuration/" flds.Item(schema & "sendusing") = cdoSendUsingPort flds.Item(schema & "smtpserver") = "mail2.mycompany.com" flds.Item(schema & "smtpserverport") = 25 flds.Item(schema & "smtpauthenticate") = cdoBasic flds.Item(schema & "sendusername") = "address-at-mycompany.com" flds.Item(schema & "sendpassword") = "123abc456" flds.Item(schema & "smtpusessl") = 1 flds.Update With imsg ..To = "evancater-at-juno.com" ..From = "Sender " ..Subject = "Test send" ..HTMLBody = "Test" ..Sender = "Sender" ..Organization = "My Company" '.ReplyTo = "address-at-mycompany.com" Set .Configuration = iconf ..Send End With Set iconf = Nothing Set imsg = Nothing Set flds = Nothing End Sub ----------------------------------------------------------------------------------------- |
|
#2
|
| THis usually happens to me when I don't give the SMTP server the information it needs in the form it needs. BTW, your code uuse both late binding and early binding. That probably has nothing to do with your problem, it's just très ugly. On Aug 26, 1:14*pm, evenlater > I'm trying to send an email from an Access procedure using CDO. I've > been able to do it successfully with three different sending email > addresses, but not with the email address I actually need to use in > production. In that case I get a message saying "The transport failed > to connect to the server." I've tried several different ports. Anybody > have any idea what the problem might be? My code is below. > > ---------------------------------------------------------------------------*-------------- > Public Sub SendEmail() > Dim imsg As Message > Dim iconf As Object > Dim flds As Object > Dim schema As String > > Set imsg = CreateObject("CDO.Message") > Set iconf = CreateObject("CDO.Configuration") > Set flds = iconf.Fields > > ' send one copy with SMTP server (with autentication) > schema = "http://schemas.microsoft.com/cdo/configuration/" > flds.Item(schema & "sendusing") = cdoSendUsingPort > flds.Item(schema & "smtpserver") = "mail2.mycompany.com" > flds.Item(schema & "smtpserverport") = 25 > flds.Item(schema & "smtpauthenticate") = cdoBasic > flds.Item(schema & "sendusername") = "addr...@mycompany.com" > flds.Item(schema & "sendpassword") = "123abc456" > flds.Item(schema & "smtpusessl") = 1 > flds.Update > > With imsg > .To = "evanca...@juno.com" > .From = "Sender > .Subject = "Test send" > .HTMLBody = "Test" > .Sender = "Sender" > .Organization = "My Company" > '.ReplyTo = "addr...@mycompany.com" > Set .Configuration = iconf > .Send > End With > > Set iconf = Nothing > Set imsg = Nothing > Set flds = Nothing > End Sub > ---------------------------------------------------------------------------*-------------- |
|
#3
|
| Thanks. I'm new at this... how would I change it to use either late or early binding? On Aug 26, 2:09 pm, lyle fairfield > THis usually happens to me when I don't give the SMTP server the > information it needs in the form it needs. > > BTW, your code uuse both late binding and early binding. That probably > has nothing to do with your problem, it's just très ugly. |
|
#4
|
| "evenlater" news:d67a5744-a594-4dcd-b3e0-7051c415a26a-at-v39g2000pro.googlegroups.com... > I'm trying to send an email from an Access procedure using CDO. I've > been able to do it successfully with three different sending email > addresses, but not with the email address I actually need to use in > production. In that case I get a message saying "The transport failed > to connect to the server." I've tried several different ports. Anybody > have any idea what the problem might be? My code is below. > > ----------------------------------------------------------------------------------------- > Public Sub SendEmail() > Dim imsg As Message > Dim iconf As Object > Dim flds As Object > Dim schema As String > > Set imsg = CreateObject("CDO.Message") > Set iconf = CreateObject("CDO.Configuration") > Set flds = iconf.Fields > > ' send one copy with SMTP server (with autentication) > schema = "http://schemas.microsoft.com/cdo/configuration/" > flds.Item(schema & "sendusing") = cdoSendUsingPort > flds.Item(schema & "smtpserver") = "mail2.mycompany.com" > flds.Item(schema & "smtpserverport") = 25 > flds.Item(schema & "smtpauthenticate") = cdoBasic > flds.Item(schema & "sendusername") = "address-at-mycompany.com" > flds.Item(schema & "sendpassword") = "123abc456" > flds.Item(schema & "smtpusessl") = 1 > flds.Update > > With imsg > .To = "evancater-at-juno.com" > .From = "Sender " > .Subject = "Test send" > .HTMLBody = "Test" > .Sender = "Sender" > .Organization = "My Company" > '.ReplyTo = "address-at-mycompany.com" > Set .Configuration = iconf > .Send > End With > > Set iconf = Nothing > Set imsg = Nothing > Set flds = Nothing > End Sub > ----------------------------------------------------------------------------------------- Because you're using late binding (ie CreateObject), and have no reference set to the CDO library, the following constants are not defined: Const cdoSendUsingPort = 2 Const cdoBasic = 1 Insert those 2 lines at the top of your procedure and give that a try. |
|
#5
|
| At http://www.ffdba.com/downloads/Send_E-Mail_With_CDO.htm there are two examples. One is all early-binding and the other is all late. On Aug 26, 5:05*pm, evenlater > Thanks. I'm new at this... how would I change it to use either late or > early binding? > > On Aug 26, 2:09 pm, lyle fairfield > > > > > THis usually happens to me when I don't give the SMTP server the > > information it needs in the form it needs. > > > BTW, your code uuse both late binding and early binding. That probably > > has nothing to do with your problem, it's just très ugly. |
|
#6
|
| On Tue, 26 Aug 2008 10:14:18 -0700 (PDT), evenlater Try this: flds.Item(schema & "sendusername") = "address" Just yesterday that helped us with some ISP. Of course the u/pw is only needed if the SMTP server requires it. -Tom. Microsoft Access MVP >I'm trying to send an email from an Access procedure using CDO. I've >been able to do it successfully with three different sending email >addresses, but not with the email address I actually need to use in >production. In that case I get a message saying "The transport failed >to connect to the server." I've tried several different ports. Anybody >have any idea what the problem might be? My code is below. > >----------------------------------------------------------------------------------------- >Public Sub SendEmail() >Dim imsg As Message >Dim iconf As Object >Dim flds As Object >Dim schema As String > >Set imsg = CreateObject("CDO.Message") >Set iconf = CreateObject("CDO.Configuration") >Set flds = iconf.Fields > >' send one copy with SMTP server (with autentication) >schema = "http://schemas.microsoft.com/cdo/configuration/" >flds.Item(schema & "sendusing") = cdoSendUsingPort >flds.Item(schema & "smtpserver") = "mail2.mycompany.com" >flds.Item(schema & "smtpserverport") = 25 >flds.Item(schema & "smtpauthenticate") = cdoBasic >flds.Item(schema & "sendusername") = "address-at-mycompany.com" >flds.Item(schema & "sendpassword") = "123abc456" >flds.Item(schema & "smtpusessl") = 1 >flds.Update > >With imsg >.To = "evancater-at-juno.com" >.From = "Sender " >.Subject = "Test send" >.HTMLBody = "Test" >.Sender = "Sender" >.Organization = "My Company" >'.ReplyTo = "address-at-mycompany.com" >Set .Configuration = iconf >.Send >End With > >Set iconf = Nothing >Set imsg = Nothing >Set flds = Nothing >End Sub >----------------------------------------------------------------------------------------- |
|
#7
|
| evenlater >Thanks. I'm new at this... how would I change it to use either late or >early binding? I'd suggest late binding once you've got the code debugged. Late binding means you can safely remove the reference and only have an error when the app executes lines of code in question. Rather than erroring out while starting up the app and not allowing the users in the app at all. Or when hitting a mid, left or trim function call. This also is very useful when you don't know version of the external application will reside on the target system. Or if your organization is in the middle of moving from one version to another. For more information including additional text and some detailed links see the "Late Binding in Microsoft Access" page at http://www.granite.ab.ca/access/latebinding.htm Tony -- Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ |
![]() |
| Thread Tools | |
| Display Modes | |