473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Strange Email Problem

I've got a button on my Access form which when i click loads a new
message in outlook.
I have got this to work on a number of forms. However it doesnt work on
on particular form in the database. And i cant understand why. It
deosnt make sense to me. When i click the button on this form i get a
Compile error - variable not defined. And it heighlights SW_SHOWNORMAL.
I have this in a module...

Public Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String, ByVal nShowCmd As Long) As Long

Here is the button code...

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim stext As String
Dim sAddedtext As String
If Len(cbemail) Then
stext = cbemail.Column(0)
End If

stext = "mailto:" & stext
If Len(sAddedtext) <> 0 Then
Mid$(sAddedtext, 1, 1) = "?"
End If
stext = stext & sAddedtext
' launch default e-mail program
If Len(stext) Then
Call ShellExecute(hwnd, "open", stext, vbNullString,
vbNullString, SW_SHOWNORMAL)
End If
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Please help someone. It doesnt seem logical to me that it works fine on
other forms but not this one.

Thanks in advance.

Nov 13 '05 #1
5 1278
I'm guessing this form cant see the module that contains ShellExecute
for some reason

Nov 13 '05 #2
One could guess that you have not declared
Public Const SW_SHOWNORMAL = 1
properly. As I recall one cannot make Public Declarations in classes
(in this case class may mean the form class module).

But this is guessing; a solution that may be frowned upon by those who
think MS will change the value of SW_SHOWNORMAL during the lifetime of
your application (or mine) is to hard code 1 in place of SW_SHOWNORMAL
so that the ShellExecute call becomes:
Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString, 1) .

Another solution might be to replace your call to the API function with
a one liner such as:

Application.FollowHyperlink "mailto:so*****@domain.com"

but I am not sure this does everything you want as I can't tell what
sAddedText does (I think absolutely nothing but it's early in the
morning here and I have had only one cup of coffee, [so far].)

I have written quite a bit of API stuff but I don't recall finding a
reason to use the ShellExecute function. Perhaps there is some unique
capability of which I am unaware.

Nov 13 '05 #3
Thanks i will try that.

sAddedText is going to be used for adding text contained in textboxes
to be used for the body of the email. I've just left that bit out for
now

Cheers.

Nov 13 '05 #4
I believe this group is filled with stories of problems with sending
e-mail with Outlook although I have not experienced them myself.
When I program sending e-mail I use CDO. It takes a little learning,
and is not particularly well presented, but it is simple and powerful:
http://msdn.microsoft.com/library/de...vr_cdo_top.asp

I'm not sure how committed to CDO MS is today, as many links lead
nowhere. But at this time it works very nicely.

Nov 13 '05 #5
Thanks its working fine now.

Cheers

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Google Mike | last post by:
I have RH9 and am using the PHP and MySQL that came with it. I was doing fine with all manner of my web pages for this app until I started having this very strange problem. It's a work order...
10
by: Carlos Ribeiro | last post by:
Hello all. I'm sending this to the list because I would like to know if someone else has ever stumbled across this one, and also because one possible solution is to patch, or simply "decorate",...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
0
by: RickVidallon | last post by:
Missing or Truncated Body Text in Email Application - 2 Strange Examples... There is no earthly reason why this is happening! EXAMPLES HERE: http://65.36.227.70/actmailer/ We have a...
4
by: John Brock | last post by:
I have a .NET application that, among other things, creates Excel workbooks, and I have run into a very strange problem involving formulas on one worksheet that reference values on another...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.