sending  EMail via ms access from a device connected to a server

Posted on 2011-05-07
Last Modified: 2012-06-27
i use two deferent ways to send EMail
you can see the attach code below
both of them are work in a proper way when i run it from any single machine.
but i have this err msg when run from a machine works under a server
"The transport failed to connect to the server"
please help, know nothing in servers

Function fnSendIntraEmail(strEMailTo As String, strMailSubj As String, strMsgBody As String)
On Error GoTo Err_fnSendIntraEmail

    Dim strDocName As String
    Dim strEmail As String
    Dim strMailSubject As String
    Dim strMsg As String

    strDocName = "rptSendMessage"
    strEmail = strEMailTo & vbNullString
    strMailSubject = strMailSub & vbNullString
    strMsg = strMsgBody & vbNullString & vbCrLf & vbCrLf & "Your Name" & _
        vbCrLf & ""
    DoCmd.SendObject objecttype:=acSendReport, _
        ObjectName:=strDocName, outputformat:=acFormatHTML, _
        To:=strEmail, Subject:=strMailSubject, MessageText:=strMsg

    Exit Function

    MsgBox err.Description
    Resume Exit_fnSendIntraEmail
End Function

Open in new window

Option Compare Database

Function fnSendEMail(tbGmailLogin As String, tbTo As String, tbPassword As String, _
                      tbMsgSubject As String, tbMsgBody As String)
On Error GoTo fnSendEMail_Err
'original code by westconn1

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = tbMsgSubject
objMessage.FROM = tbGmailLogin
'objmessage.To = Me.tbTo & ""
objMessage.To = tbTo
objMessage.TextBody = tbMsgBody
'objMessage.AddAttachment "c:\EMail_temp\tblBills.txt" '  --> change it for the path of your file(attachment)

 objMessage.Configuration.Fields.Item _
("") = 2
'Name or IP of Remote SMTP Server
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("") = 1
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("") = tbGmailLogin
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("") = tbPassword
objMessage.Configuration.Fields.Item _
("") = ""
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("") = 465
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("") = 30
Set objMessage = Nothing

'Call MsgBox("E-mail sent via Gmail SMTP", vbInformation, Application.Name)
MsgBox " Êã ÅÑÓÇá ÑÓÇáÊß ", vbExclamation

    Exit Function

    MsgBox Error$
    Resume fnSendEMail_Exit

End Function
Function fnExportToTxt()
On Error GoTo fnExportToTxt_Err

DoCmd.TransferText acExportDelim, , _
    "tblBills", "C:\EMail_temp\tblBills.txt"

    Exit Function

    MsgBox Error$
    Resume fnExportToTxt_Exit

End Function

Open in new window

Question by:M_SOLAIMAN
    LVL 84
    What do you mean by "machine works under a server"? Can you describe the environment a bit more clearly?
    LVL 39

    Accepted Solution

    If your server have firewall enabled - port  465 should be opened for output

    Author Comment

    i mean any pc connect to a lan (local network)
    the operating system is windows 2000 server
    i can figure out that they use port no 8080 for internet
    can i use that port instead
    LVL 84

    Assisted Solution

    by:Scott McDaniel (Microsoft Access MVP - EE MVE )
    Sendobject uses the default email client on the machine. Do you have an email client installed and configured on the workstations? If so, make sure to test the email client to insure it can send and receive email.

    Note also that your email system may be setup to disallow external programs from using it.

    Do you know what email system you're using?

    Author Comment

    "Do you have an email client installed and configured on the workstations"
    I don’t know what u mean by "email client"
    Do you know what email system you're using?
    Do you mean by " email system you're using" outlook for examble?
    If so? Then I use outlook.
    I try telnet on the server (which I have the problem) and on my pc(which works in appropriate way)
    But I get the same result "connect failed"
    So it seem to me is nothing to do with the port? Maybe! Actually I am 0 level in networking.


    Author Comment

    "If your server have firewall enabled - port  465 should be opened for output"
    How to enable that port please?
    LVL 39

    Assisted Solution

    Try telnet to smtp server's ( port 465
    telnet 465
    If you will not be able to do it, you should know - what firewall (proxy) is installed on your server.
    Are you sure - is address of Windows 2000 server? More likely it is hardware firewall (router). In this case you should find it's model.

    Author Comment

    I am sorry
    I was telnetting to IPv4 address on my PC, and that's why I get failed.
    But when I telnetting to Default Gateway , I got the "clear DOS Prompt"
    At server side, the tech guy telnet on that port "465" and it's failed.
    So I will request from the IT department to open that port, and see what will happen.
    I am trying to make a small test environment, (windows server 2003, and one client) , and try to send an Email from my ms access program.
    If I get the same error, I will try to open the port on the server, then try again.
    Maybe this scenario will help solving the problem. I hop.

    Author Closing Comment

    thanks to every body

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now