Email Automation stopped working
-
Donnerstag, 14. Februar 2013 17:29
oKay thanks everyone for all your wonderful help over the last two years. You are all great.
So I had this code that was working to send an email at the click of a button. Using Outlook, Exchange Server, No Objects. Suddenly today it stopped working with an error. I have tried rebooting, verified references, Compiling, Compact & Repair, Importing into a new shell. I don't know what else to do. Any Ideas?
Here is the message:
here is the code.
Option Compare Database Option Explicit Function SendMessage() Dim mapOutlook As Outlook.Application Dim mapNameSpace As NameSpace Dim mapFolder As Folder Dim mapMessage As MailItem Dim objOutlookRecip As Outlook.Recipient Dim strMsg As String Dim strSig As String Set mapOutlook = CreateObject("Outlook.Application") Set mapNameSpace = mapOutlook.GetNamespace("MAPI") mapNameSpace.Logon Set mapFolder = mapNameSpace.GetDefaultFolder(olFolderOutbox) Set mapMessage = mapOutlook.CreateItem(olMailItem) mapMessage.Recipients.Add "Me@Email.com" mapMessage.Subject = "Subject" strMsg = "<div><p>Message</p></div>" strSig = "<div>" strSig = strSig & "<p style='margin:0in;margin-bottom:.0001pt'>My Name<o:p></o:p></p>" strSig = strSig & "<p style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.0pt;color:#0046F6'>IT System Technician<o:p></o:p></span></p>" strSig = strSig & "<p style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.0pt;color:#0046F6'>ALDOT Computer Services<o:p></o:p></span></p>" strSig = strSig & "<p style='margin:0in;margin-bottom:.0001pt'><span style='font-size:10.0pt;font-family:'Times New Roman','serif'; color:#31849B'><a href='https://MyEmailDomain/owa/redir.aspx?C=a660dcc82a744a28a0b19aa5bb140a25&URL=mailto%3aMyEmail@MyDomain' target='_blank'><span style='font-family:'Calibri','sans-serif';color:blue'>MyEmail@MyDomain</span></a></span><span style='font-size:10.0pt;font-family:'Times New Roman','serif';color:blue'><o:p></o:p></span></p>" strSig = strSig & "</div>" mapMessage.HTMLBody = "<html><body>" & strMsg & strSig & "</body></html>" mapMessage.Save mapMessage.Send Set mapMessage = Nothing Set mapFolder = Nothing Set mapNameSpace = Nothing Set mapOutlook = Nothing End Function
Thank you for your help!!!
Chris Ward
Alle Antworten
-
Donnerstag, 14. Februar 2013 20:05
That's not an error message, that's a standard e-mail security message from Outlook, and it means just what it says. It was part of the security measures put in place some years ago to prevent viruses from distributing themselves via e-mail from users' systems unbeknownst to the users. Did you try clicking the Help button?
I'm surprised you haven't seen this before, though, as this protection has been in place for quite a while. Originally, IIRC, you had to click an approval for every message, but in a later version they amended it to allow you to specify a time period, so you can send multiple messages in an e-mail blast without having to approve every one. Have you recently applied an update to Outlook?
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html- Als Antwort markiert KCDW Donnerstag, 14. Februar 2013 22:55
-
Donnerstag, 14. Februar 2013 20:57
Hi Dirk,
No updates that I am aware of. I know it's not an error message. I just call it that because this was working before and now it isn't. I had that message before I started using this code so I thought maybe something went wrong with the code or the app to make it stop. You remember you helped with the code afterall. But now it's not working again so I need some help to get around it. I am only emailing myself and my supervisor.
Chris Ward
-
Donnerstag, 14. Februar 2013 22:31What gets me even more is I can set up a macro to send an object through email and it gets right through the email program fine. I don't need to send an object though. Whats worse is using Access convert to VBA doesn't convert on the email code. That seems weird to me.
Chris Ward
-
Donnerstag, 14. Februar 2013 22:55Well I guess I can get used to hitting the allow button for added security sake.
Chris Ward
-
Freitag, 15. Februar 2013 02:44
No, no, no, don't get used to it. Download and run the tiny utility below, and go get a cup of coffee while all emails are sent automatically:
http://www.contextmagic.com/express-clickyes/
Ryan Shuell
-
Freitag, 15. Februar 2013 14:07
What gets me even more is I can set up a macro to send an object through email and it gets right through the email program fine. I don't need to send an object though. Whats worse is using Access convert to VBA doesn't convert on the email code. That seems weird to me.
So, in other words, the SendObject macro works without triggering the message, but automating Outlook doesn't? I'm not sure why that is, and can only guess that it works because the Access database itself is trusted. But I haven't tested this.Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
Freitag, 15. Februar 2013 14:11
Well I guess I can get used to hitting the allow button for added security sake.
As Ryan says, there are ways to work around this, among them ClickYes, PTFB -- both of which work by simply watching for the appearance of the dialog box and "clicking" the button for you -- and Outlook Redemption, which has a way of preventing the dialog from appearing at all. One can even go so far as to construct one's own SMTP server, something I had to implement once for a client, though it's a lot of trouble.
I am still puzzled as to why you suddenly started getting the security dialog now, when you didn't before. Clearly something changed, but what?
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
Freitag, 15. Februar 2013 14:24
No, no, no, don't get used to it. Download and run the tiny utility below, and go get a cup of coffee while all emails are sent automatically:
http://www.contextmagic.com/express-clickyes/
Ryan Shuell
Thanks Ryan, but as I mentioned the last time you brought this up I am not authorized to spend money on this project and the version that will work costs money. I have to build in code only, no third party anything.Chris Ward
-
Freitag, 15. Februar 2013 14:31
So, in other words, the SendObject macro works without triggering the message, but automating Outlook doesn't? I'm not sure why that is, and can only guess that it works because the Access database itself is trusted. But I haven't tested this.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html
The send object does work as a Macro, and I was finally able to get it to convert to VBA but once converted it popped the same message box. The db is in a trusted location. The other problems after converting to VBA is I couldn't find a method for sending to multiple recipients. I need to send it to me and my supervisor. I could use To once, cc Once etc. but I could not add a separator for multiple and I also haven't figures out how to add the signature stuff back in from the original method you helped me with. But why bother if it doesnt work anyway.Chris Ward
-
Freitag, 15. Februar 2013 14:57
What gets me even more is I can set up a macro to send an object through email and it gets right through the email program fine. I don't need to send an object though. Whats worse is using Access convert to VBA doesn't convert on the email code. That seems weird to me.
So, in other words, the SendObject macro works without triggering the message, but automating Outlook doesn't? I'm not sure why that is, and can only guess that it works because the Access database itself is trusted. But I haven't tested this.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.htmlHi Chris,
Is it something like what happens in Outlook Express? You can send as many mails by hand as you want, but when you send automatic mails you get, after 100 mails, a warning to compact Outlook Express.
Just by setting the "Compact Check Count" back to 0 you can send another 100 automatic mails without warning.
Before starting an automatic mailing I set (with a little piece of code) the value to 0, and when it reaches number 95 I reset it again: no warnings any more.
Imb.
-
Freitag, 15. Februar 2013 14:58
The send object does work as a Macro, and I was finally able to get it to convert to VBA but once converted it popped the same message box. The db is in a trusted location. The other problems after converting to VBA is I couldn't find a method for sending to multiple recipients. I need to send it to me and my supervisor. I could use To once, cc Once etc. but I could not add a separator for multiple and I also haven't figures out how to add the signature stuff back in from the original method you helped me with. But why bother if it doesnt work anyway.
You can use multiple addresses separated by semicolons in any of the To, CC, or BCC arguments. But SendObject only supports plain text format, not HTML format. Of course, you can create a plain-text signature and tack it onto the end of your message body.
It's interesting that DoCmd.SendObject pops up the security dialog, but the SendObject macro doesn't. I wasn't aware of that.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
Freitag, 15. Februar 2013 15:03
1) PTFB
2) Outlook Redemption, which has a way of preventing the dialog from appearing at all.
3) One can even go so far as to construct one's own SMTP server
4) I am still puzzled as to why you suddenly started getting the security dialog now, when you didn't before. Clearly something changed, but what?
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html1) What is PTFB - is it like an open source so I can use what is in it instead of it?
2) Ditto
3) Not going to happen here
4) It is a puzzle especially since the message is different from the message that prompted me to use the code that worked. Both messages are on the webpage provided by Ryan above. My guess is the email group in NetOps increased the security settings. Maybe I can ask them for a workaround. HaHa.
Chris Ward
-
Freitag, 15. Februar 2013 15:07
Is it something like what happens in Outlook Express? You can send as many mails by hand as you want, but when you send automatic mails you get, after 100 mails, a warning to compact Outlook Express.
Just by setting the "Compact Check Count" back to 0 you can send another 100 automatic mails without warning.
Before starting an automatic mailing I set (with a little piece of code) the value to 0, and when it reaches number 95 I reset it again: no warnings any more.
Imb.
Good Morning IMB,
Hunh? from Fantastic Mr. Fox "Does anyone know what this badger is talking about"?
I use Outlook 2007 here at work. I am not familiar with any setting like that. Where would I find it? What code would I use?
Chris Ward
-
Freitag, 15. Februar 2013 15:14
1) What is PTFB - is it like an open source so I can use what is in it instead of it?
2) Ditto
3) Not going to happen here
4) It is a puzzle especially since the message is different from the message that prompted me to use the code that worked. Both messages are on the webpage provided by Ryan above. My guess is the email group in NetOps increased the security settings. Maybe I can ask them for a workaround. HaHa.
1. PTFB stands for "Push The Freakin' Button!", a utility similary to ClickYes. It's not open source, but it used to be purely freeware. Now there is a "pro" version for which you have to pay; however, I believe you can still download a copy of the old freeware version if you look around for it.
I think it wouldn't be hard to write code that could run in, say, a form's Timer event, that would use Windows API calls to watch out for the appearance of the security dialog and send it a button-click message. However, I don't have the time to do that this month. <g>
2. Outlook Redemption is the name of an object library that one calls instead of automating Outlook directly. I haven't worked with it, but Google and Bing are your friends.
3. Just trying to enumerate all the possibilities.
4. I suppose it could be a change from your IT side. I don't know. As for your "HaHa", I feel your pain.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
Freitag, 15. Februar 2013 15:16Outlook Express and its descendent, Windows Mail are not the same as Outlook at all. I doubt that the issue Imb refers to occurs with Outlook, and it's not the issue you're experiencing, anyway.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
Freitag, 15. Februar 2013 15:19
I was under the impression that ClickYes was free, or there is one version that is free.
Also, see this:
http://msdn.microsoft.com/en-us/library/ms778202.aspx
http://www.dimastr.com/redemption/home.htm
Ryan Shuell
-
Freitag, 15. Februar 2013 15:36
No, no, no, don't get used to it. Download and run the tiny utility below, and go get a cup of coffee while all emails are sent automatically:
http://www.contextmagic.com/express-clickyes/
Ryan Shuell
Thanks Ryan, but as I mentioned the last time you brought this up I am not authorized to spend money on this project and the version that will work costs money. I have to build in code only, no third party anything.
Chris Ward
Chris
I use vbMAPI from EverythingAccess It's only $95 for one licence. All you need is one licence. Your users won't need a licence. And, come on! $95 is chump change for any IT department. They probably have 3 times that in their petty cash.
Maybe if you approached the IT manager and told him vbMAPI can be used in so many ways it begs to be added to every database application. The uses I've found are
- notifying users about new features
- sending out shortcuts to new users for installing apps
- sending users instructions if they lost their passwords
- notifying me if an error occurred (users never tell you)
- notifying users about down time for maintenance or repair.
The help files all contain great sample code. I implemented it the first time and all I needed to do was copy and paste the sample code.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Freitag, 15. Februar 2013 15:40
So, in other words, the SendObject macro works without triggering the message, but automating Outlook doesn't? I'm not sure why that is, and can only guess that it works because the Access database itself is trusted. But I haven't tested this.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.htmlDirk Something is different about Chris's setup. SendObject should trigger the warning, too. At least it did on all environments I've worked in.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Freitag, 15. Februar 2013 15:44
You're right, Bill. I just tested (Access 2003, Vista) and it popped up the security dialog for me.Dirk Something is different about Chris's setup. SendObject should trigger the warning, too. At least it did on all environments I've worked in.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html -
Freitag, 15. Februar 2013 17:42
Bill you are a jinx now I can't get the Macro to work either. I had the Macro embeded in the button control yesterday and during testing it worked but I wanted to move the Macro outside of the Form and thats when it quit working. Then I put it back into the Form and it worked again. Then I converted it to VBA and it quit. I rebuilt the Macro and it worked yesterday but like I said it did not innclude all that I needed. Today that macro no-longer works. I think I will just live with it.Dirk Something is different about Chris's setup. SendObject should trigger the warning, too. At least it did on all environments I've worked in.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_ProfessionalsChris Ward
-
Freitag, 15. Februar 2013 17:44
I cannot spend any money on this project. It is not allowed.I use vbMAPI from EverythingAccess It's only $95 for one licence. All you need is one licence. Your users won't need a licence. And, come on! $95 is chump change for any IT department. They probably have 3 times that in their petty cash.
Maybe if you approached the IT manager and told him vbMAPI can be used in so many ways it begs to be added to every database application. The uses I've found are
- notifying users about new features
- sending out shortcuts to new users for installing apps
- sending users instructions if they lost their passwords
- notifying me if an error occurred (users never tell you)
- notifying users about down time for maintenance or repair.
The help files all contain great sample code. I implemented it the first time and all I needed to do was copy and paste the sample code.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_ProfessionalsChris Ward
-
Freitag, 15. Februar 2013 17:45Hey my (MCC) tag disappeared this morning.
Chris Ward
-
Freitag, 15. Februar 2013 17:52
Bill you are a jinx
Chris Ward
Ha-ha-ha! You're too funny, Chris.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Freitag, 15. Februar 2013 17:58
oKay I think I am narrowing this down.
It works if you don't have the recipient listed. The it is actually using Outlook to put in the names instead of Macros or VBA.
Does this sound right to you guys?
Chris Ward
-
Freitag, 15. Februar 2013 18:44
oKay I think I am narrowing this down.
It works if you don't have the recipient listed. The it is actually using Outlook to put in the names instead of Macros or VBA.
Does this sound right to you guys?
Chris Ward
Chris - That makes sense. If you open the email for editing the Outlook security shouldn't kick in because the user sees the email and has to manually send it. Maybe that's why you never saw the warning before. Your user had to click the Send button, right?
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Freitag, 15. Februar 2013 20:14
Not exactly,
I am the user and until yesterday I didn't have to click anything to make it work because I was not receiving any message. Only yesterday and today did I hit a send button and then only on the Macro. Before yesterday for several weeks the code in the OP worked perfectly.
Something changed I don't know what.
Chris Ward
-
Freitag, 15. Februar 2013 20:40
Not exactly,
I am the user and until yesterday I didn't have to click anything to make it work because I was not receiving any message. Only yesterday and today did I hit a send button and then only on the Macro. Before yesterday for several weeks the code in the OP worked perfectly.
Something changed I don't know what.
Chris Ward
I have no idea how the warning never came up before unless you used to have .Display instead of .Send
.Display opens the email for editing. It doesn't get sent until the user (you) clicks the send button.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Freitag, 15. Februar 2013 20:51
Not in this case Bill,
The code in the Original Post did not open the email for anything. It silently created and sent the email to the recipients. No message box was displayed until after weeks of working.
Chris Ward
-
Freitag, 15. Februar 2013 23:06
Chris
All I can say is that is very strange. That stupid warning has come up since Access 2000. I don't know how you never got it.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Dienstag, 26. Februar 2013 14:19
UPdate:
Suddenly this morning it is working again without any changes. No more prompts for allowing. We'll have to see how long it lasts.
Chris Ward
-
Dienstag, 26. Februar 2013 15:46
UPdate:
Suddenly this morning it is working again without any changes. No more prompts for allowing. We'll have to see how long it lasts.
Chris Ward
Chris
If you ever find out why you do not get prompts when everyone else does (unless they are using a third-party work-around) I'd love to hear about it.
Bill Mosca
www.thatlldoit.com
http://tech.groups.yahoo.com/group/MS_Access_Professionals -
Dienstag, 26. Februar 2013 17:29
Suddenly this morning it is working again without any changes. No more prompts for allowing. We'll have to see how long it lasts.
Very peculiar. I can't help thinking it's something your IT department is doing.Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

