Results 1 to 7 of 7
  1. #1
    alyon is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    89

    VBA Email on DSL

    This might be a silly question, but I have vba email code working perfectly fine through a wireless router network.

    Set objMessage = CreateObject("CDO.Message")
    myAttachment = "C:\Documents\Folder\Name" & ".pdf"
    objMessage.Subject = "Subject"
    objMessage.From = "send@email.com"
    objMessage.Cc = "send@email.com"
    objMessage.To = "sendto@email.com"
    objMessage.TextBody = "Hello "
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...tpauthenticate") = 1
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...n/sendusername") = "email@stny.rr.com"
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...n/sendpassword") = "password1234"
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "smtp-server.stny.rr.com"
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...smtpserverport") = 25
    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...ion/smtpusessl") = false


    objMessage.Configuration.Fields.Item_("http://schemas.microsoft.com/cdo/con...nectiontimeout") = 60
    objMessage.Configuration.Fields.Update
    objMessage.SEND
    Set objMessage = Nothing
    i = MsgBox("Email Sent", vbOKOnly, "Email Sent")

    I tried to incorporate it in another office, and I kept getting run time error 438, highlighting the sendusing = 2 line.
    The only difference I noticed was that this office was using an Ethernet cable through a phone jack in the wall, rather than a wireless router.
    I tried different ports and well as 1 and 3 for sendusing.
    Would this make a difference? If so, is there a solution to change something so I can use it there too?


    Any help would be appreciated.
    Thank you!
    alyon

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Since Wireless and Wired are simply the Transport Layer, I don't think it should make any difference at all. I'm researching RunTime error 438.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Run Time Error 438 - Object Doesn't Support this Property or Method

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are both systems using the same version of Office?

  5. #5
    alyon is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    89
    yes, same versions of office.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Here's the template I've used for years on CDO email
    Code:
    Public Function SimpleSendEMailWithCDO() As Boolean
       Dim iCfg As Object
       Dim iMsg As Object
       On Error GoTo SimpleSendEMailWithCDO_Error
       Set iCfg = CreateObject("CDO.Configuration")
       Set iMsg = CreateObject("CDO.Message")
       With iCfg.Fields
          ' Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
          ' Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
          .Item("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2
          .Item("http://schemas.microsoft.com/cdo/con...smtpserverport") = 25
          .Item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "mail.so.centurytel.net"
          ' cdoBasic 1
          ' Use basic (clear-text) authentication.
          ' The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.
          .Item("http://schemas.microsoft.com/cdo/con...tpauthenticate") = 1
          .Item("http://schemas.microsoft.com/cdo/con...n/sendusername") = "UserName"
          .Item("http://schemas.microsoft.com/cdo/con...n/sendpassword") = "UserPassword"
          .Item("http://schemas.microsoft.com/cdo/con...ndemailaddress") = ""
          ' 'Use SSL for the connection (False or True)
          .Item("http://schemas.microsoft.com/cdo/con...ion/smtpusessl") = False
          ' 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
          .Item("http://schemas.microsoft.com/cdo/con...nectiontimeout") = 60
          .Update
       End With
       With iMsg
          .configuration = iCfg
          .Subject = "Your Subject"
          .To = ""
          .Cc = ""
          .Bcc = ""
          .TextBody = "See attachment"
          .AddAttachment CurrentProject.Path & AttachFile
          .Send
       End With
       Set iMsg = Nothing
       Set iCfg = Nothing
       SimpleSendEMailWithCDO = True
       
    SimpleSendEMailWithCDO_Exit:
       On Error GoTo 0
       Exit Function
    SimpleSendEMailWithCDO_Error:
       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SimpleSendEMailWithCDO of Module basCDO"
       SimpleSendEMailWithCDO = False
       Resume SimpleSendEMailWithCDO_Exit
       
    End Function

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try separating it out as shown in my sample.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Email report as body of email (RTF)
    By TheDeceived in forum Programming
    Replies: 4
    Last Post: 07-23-2012, 06:39 AM
  2. Export to PDF and Email multiple PDF's per email
    By greyoxide in forum Reports
    Replies: 1
    Last Post: 04-20-2012, 08:49 AM
  3. Email report as body of email
    By chrish20202 in forum Programming
    Replies: 6
    Last Post: 01-15-2012, 07:23 PM
  4. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  5. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums