Solved

Workaround email security message "...trying to automatically send e-mail on your behalf"

Posted on 2003-11-12
20
19,759 Views
Last Modified: 2008-11-27
In Access2000, trying to automate some notifications in an unattended, scheduled process, using docmd.sendobject to send email gives message "A program is trying to automatically send email on your behalf...".  Is there any way to work around this or otherwise email from Access/VB?
0
Comment
Question by:keyboards
  • 4
  • 4
  • 3
  • +7
20 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9736296
keyboards:

> In Access2000, trying to automate some notifications in an unattended, scheduled
> process, using docmd.sendobject to send email gives message "A program is
> trying to automatically send email on your behalf...".  Is there any way to
> work around this or otherwise email from Access/VB?

See this question:
http://www.experts-exchange.com/Applications/Email/Q_20695108.html

Hope that helps,
Dex*
0
 
LVL 2

Accepted Solution

by:
Team929 earned 250 total points
ID: 9736461
This is what I use. Hope it helps. Combination of what I found and what I added (not much added really).

Function SendEmail(strTo, strMessage, strAttach, strSubject, strBCC)

   Set objEmail = CreateObject("CDO.Message")
      objEmail.FROM = "myEmail@emailadd.com"
      objEmail.To = strTO '//// format "abc@emailadd.com; edf@emailadd.com"
      objEmail.BCC = strBCC
      objEmail.Subject = strSubject
      objEmail.TextBody = strMessage
      objEmail.AddAttachment strAttach
      objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpservername.com"
      objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      objEmail.Configuration.Fields.Update
      objEmail.Send
      Set objEmail = Nothing

End Function
0
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9736981
Team929 demonstrates how to go through proxies, - if you don't need this but prefer SMTP directly you can also do:

Public Function skMsgCDO()

' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library

Dim iConf As New CDO.Configuration, iMsg As New CDO.Message, Flds  As ADODB.Fields
Dim skFromName As String, skFromAddr As String, skToName As String, skToAddr As String
dim skMailServer As String, skMailAccount As String

' Config for SMTP mail-account
    skMailServer = "mail.somecom.com"
    skMailAccount = "xx"

' Contents for the message
    skFromName = "Full Name"
    skFromAddr = "xx@somecom.com"
    skToName = "Full Name"
    skToAddr = "yy@someothercom.com"
    skCC = "" ' just comma or semicolon separated e-mail address list
    skSubject = "Your lights are on, but no one is home"
    skBody = "You left your lights on this morning."

' Set the configuration for Network Send
    Set Flds = iConf.Fields
    Flds(cdoSendUsingMethod) = cdoSendUsingPort
    Flds(cdoSMTPAccountName) = skMailAccount
    Flds(cdoSMTPServer) = skMailServer
    Flds(cdoSMTPServerPort) = 25
    Flds(cdoSMTPConnectionTimeout) = 30
    Flds.Update

' Do the message
    Set iMsg.Configuration = iConf
    With iMsg
       .From = Chr(34) & skFromName & Chr(34) & skFromAddr
       .CC = skCC
       .Subject = skSubject
       .TextBody = skBody
       .To = Chr(34) & skToName & Chr(34) & skToAddr
       .Fields(cdoDispositionNotificationTo) = ""
       .Fields.Update
       .Send
    End With

' Finished
    Set iMsg = Nothing
    Set iConf = Nothing

End Function



Kind regards,
Sven
0
 
LVL 1

Expert Comment

by:OracleSWN
ID: 9736992
Team 929,

In the Config.Fields.... can you explain the format? I understand most everything else, but am having a hard time following those three areas. Thanx
0
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9737000
0
 
LVL 2

Expert Comment

by:Team929
ID: 9737070
OracleSWN,

Let me try but like I said, I found it orignally somewhere and truncated and made it so that its easily accessable from anywhere in the code as long as you put in the required variables.

     Configuration.Fields.Item(...) = 2
This is the one I'm not all that sure about but from what I can gather and remember, its the way you send the email. Something like how 0 represents acImport, 1 is acExport and such.
      Configuration.Fields.Item(...) = "smtpservername.com"
Obviously, it sets the name of the smtp server.
      Configuration.Fields.Item(...) = 25
This is the default port to be used. Much like how port 21 is the default port for FTP.

Hope this helps.

0
 
LVL 1

Expert Comment

by:OracleSWN
ID: 9737477
Team 929,

Hate to jump in this string, but I will give you points if I can grasp this idea as well. I am having the same issue. I am trying to use your function and I was wondering two things.

1- what is the Http's listed in the Configs
2- what references do I need to use this function
0
 
LVL 1

Expert Comment

by:OracleSWN
ID: 9737534
Team929,

Hey... your code works great! Last question how can I attach an object out of my db now? =) last question promise. will give you points.
0
 
LVL 2

Expert Comment

by:Team929
ID: 9737642
umm.. okay... I wonder where the original poster went?
Anyhow, I'm glad its working for you.

As for the attachment, it has to be a full path to a file: .mdb, .xls, etc. So if you want to attach a report, I think you need to export it to a fresh .mdb first and attach that. I've always used the email function as a notice, like "something is done" or "reminder" set on an event or scheduled task.

"strAttach" has to have a value like "\\servername\filename.mdb" or "C:\localdrive\finename.doc".
0
 
LVL 1

Expert Comment

by:OracleSWN
ID: 9737723
Team929,

Please see below for your points.

http://www.experts-exchange.com/Databases/MS_Access/Q_20796527.html
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Expert Comment

by:the_roster
ID: 10201665
CLIENT SIDE SOLUTION :)

To resolve the problem from a client side approach, they must have the following registry key added whcih will suppress Outlook from prompting them…

HKCU\software\policies\microsoft\policies\security…  DWORD=checkadminsettings value must be 1
0
 

Author Comment

by:keyboards
ID: 10202211
To Team929 - I'm here, you did know I accepted your answer back in Nov'03, right?  Great info from everyone, and always like to know multiple ways to go about something.  Thanks again! :0}
0
 

Expert Comment

by:kevinoakes
ID: 10756304
I have set up a field as e-mail in access and made it a hyperlink when I try to send e-mail in a form using this I get the message cannot find proxy server can u explain how I can snd e-mail by clicking on the address I am making a front end using sql and vba for access, I am an amatuer!! at using access
0
 

Author Comment

by:keyboards
ID: 10759502
Do you mean you have a hyperlink datatype for a field in a table in access?  If so, you have to specify the address in the form of "mailto:email@domain.com" to get it to bring up your default email browser/editor, if you have one set up.  Lemme know how it goes.  Email addy is keyboards@yahoo.com
0
 

Expert Comment

by:FPJCB
ID: 12124855
I looked for HKCU\software\policies\microsoft\policies\security…  on my computer so I could change the DWORD=checkadminsettings value to 1 and I can't find it.  What needs to be set up on my computer to have this setting in my registry?  Am I missing something I need for this?  I get that same "The computer is sending email on your behalf" box and I'd love to be able to make a simple change in the registry to solve the problem if that doesn't create other problems for me.

  Thanks,

    Jeff
0
 

Expert Comment

by:Philbee
ID: 12627286
I'm currently adding the accepted answer to my application but have no idea what the objEmail should be declared as.  is it an outlook.application or an outlook.mailitem?
Could someone help?? cheers. Philbee
0
 

Author Comment

by:keyboards
ID: 12629658
Philbee,

Make sure you include the "Microsoft CDO 1.21 Library" by checking it in the VB editor...Tools...References

Then...

    Dim objEmail As New CDO.Message

Hope this helps.

keyboards
0
 

Author Comment

by:keyboards
ID: 12629783
FPJB - if it doesn't exist, you must create it, all levels, in the registry

keyboards
0
 

Expert Comment

by:Philbee
ID: 12643455
cheers for the comment keyboards.  Am working it now. If I'm successful I will have to get some points to you somehow.  
0
 
LVL 1

Expert Comment

by:Drumsticks
ID: 12960434
Hello,

I included the "Microsoft CDO 1.21 Library" and the "Microsoft CDO For Exchange 2000 Library", but I am still receiving an error on the 'objEmail.Send' line.

The error states "The transport failed to connect to the server."

What am I missing here?

Regards,
Drumsticks

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

747 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