Windows 7 ans smtp mail on Access 2003 (1 Viewer)

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
Hi

I designed a database a few years back that sends automatic e-mail though the smtp port. This is because we use Novell Groupwise instead of Outlook.

This is the code:
Code:
    rst.Close
    dbs.Close
    Set rst = Nothing
    Set dbs = Nothing

Set mail = Nothing

' Send by connecting to port 25 of the SMTP server.
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strEmailTo

Const cdoSendUsingPort = 2

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

' Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    'ToDo: Enter name or IP address of remote SMTP server.
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.1.10.63"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
    .Update
End With

' Build HTML for message body.
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> </b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

' Apply the settings to the message.
With iMsg
    Set .Configuration = iConf
    .To = strEmailAddress
    .cc = CarbonCopy
    .From = "Airplane R&D Database. R&D Staff Entry." 'MailFrom 'this should be OK
    .Subject = "R&D ID# " & RDID & ".  " & ProjectName & ". By " & Commentby
    .HTMLBody = TestInput  'this should be OK
    .Send   'this should be OK
End With

' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

Unfortunately, one of the users has now been upgraded to Windows 7, and since this happened, when the db attempts to send an e-mail, he gets the following message: "Runtime error -2147220979(8004020d) At least one of the froms or sender fields is required"

Everyone else is still able to send e-mails normally.

Does anyone know what is happening?

Thanks

mafhobb
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 12:17
Joined
Sep 7, 2009
Messages
1,819
Does it hang on a particular line?
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
It does not appear to do so, but I do not know for certain yet. I am not on location and can't check the computer first hand.

I'll try get someone with more Access experience than the user to check.

mafhobb
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 12:17
Joined
Sep 7, 2009
Messages
1,819
Ah - you'll need to see the line the code stops on before we can help further, I think... if your user is using an MDE instead of and MDB they won't see the code, you'll have to replicate the problem using the MDB.
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
Maybe the name isn't being resolved to an existsing e-mail address. Try using an e-mail address in the FROM field instead of the alias.
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
I should be able to remote log in to see what line is giving the problem today. However, since nobody else is having the problem except for the one guy that just got updated to Windows 7, I am a lot more inclined to think that the problem is OS related, not db-code related.

Any ideas?

mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
I haven't yet used Win 7 but I wouldn't have thought there was a different configuration. You could try putting a DoEvents before .Send

In the meantime, have you been able to track the error line?
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
Hi vbaInet.

Hopefully I'll be able to remote loggin to the computer that is having the problem this evening.

By the way, I have researched the DoEvents command and it seems like it is basically a command to allow the computer to finish whatever it is currently doing before moving on through the code (sorry for my lack of understanding if this in not the case). If so, why would this be needed? Wouldn't the code itself specify the order things need to happen?

Thanks

mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
Exactly what it does. There are certain times that code execution needs to halt at a point to allow it to finish before it's allowed to proceed. Your case might be one.

Let us know what you unveil.
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
Ok...It is the .send that is triggering the error.

Suggestions?

mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
Have you tried the DoEvents? It's quite common practice to free up processing.

Also can you send via command prompt?
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
My next step is to do the DoEvents. Unfortunately, since this db is not split yet, I have to wait until everyone is off. I'll probably get it done later today or tomorrow morning.

Also, what do you mean by "send via command prompt"?

Mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
An unsplit db? Not good mafhobb.

I still think that is could also be the aliases not being resolved. So what you could also do is try putting in static e-mail addresses in the FROM and TO fields.

It's been a while I tried doing it via command prompt. Google and see what you come up with.
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
I finally had access to the computer that is having the problem and here is what I found:

Adding "DoEvents" in the code did not seem to make a difference. I added it in several different places and I still got the same error message.

I found that the line that is giving the trouble is
Code:
    .From = "Airplane R&D Database. R&D Staff Entry."
. Replacing this with a real of fake e-mail (like me@noserver.com) fixed the problem.

I want to avoid that solution if I can as there are a few e-mail accounts out there that use the text "Airplane R&D Database. R&D Staff Entry." in the subject line as a trigger to a rule.

Does anyone know why this line of code would work in XP but create this problem in Windows 7? Does Windows 7 go through an additiona step to check if the .from field contains a valid (at least in format) e-mail address?

Thanks

Mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
We would have saved ourselves time if you had tried that as initially suggested.

Ask the person if they have Outlook setup on their machine. If they do, ask them to send an e-mail to "Airplane R&D Database. R&D Staff Entry." via Outlook and see if it's received.

If all that's fine then change your FROM line to this:

Code:
.From = """Airplane R&D Database. R&D Staff Entry.""  <me@noserver.com>"
The only thing you change is the e-mail address, leave the spacing.
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
Hi. Outlook is not installed on this machine. We use Novell Groupwise. That is why I needed to use the smtp instead of sending the mail out as an outlook object.

...but...in order to understand this...what does the like of code do? I mean, what do your changes do when compared to the original code?

.From = """Airplane R&D Database. R&D Staff Entry."" <me@noserver.com>"

BTW, yesterday was the first time I had access to the machine and it was very helpful to have your input to troubleshoot it.

Thanks

mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
I see, that's why you're using CDO. Notice that the aliased field is in quotes meaning it should treat as text but still display it in the From field, and use the e-mail address supplied. However, I think if you supply just the e-mail address the Smtp server should be able to resolve it and display the alias + e-mail address.

If the .From doesn't work, there's a .Sender method you could try.
 

mafhobb

Registered User.
Local time
Today, 06:17
Joined
Feb 28, 2006
Messages
1,245
Re: Windows 7 ana smtp mail on Access 2003

Yes, this worked. Thanks vbaInet!

Still, any idea why the code would need to be different when using XP or Windows 7?

mafhobb
 

vbaInet

AWF VIP
Local time
Today, 12:17
Joined
Jan 22, 2010
Messages
26,374
I have no idea i'm afraid. I don't know the framework of Win 7. However, when using aliases that's the way to qualify the address field so maybe that's fully enforced on the Win 7 communication setup.

Glad that worked for you.
 

Users who are viewing this thread

Top Bottom