Send email from data access form - Subject Problem

  • Thread starter Michael J. Earl
  • Start date
M

Michael J. Earl

I am trying to create an email send from a data access form.

No problem to enter the address:- just enter mailto:[email protected] in the
email address field.

No problem to display required text in the Hyperlink field on the form -
Hyperlink.ControlSource: Expr2: "email Web Application Job No " & [JobCode]
(where JobCode is another field (integer) on the form) eg. "email Web
Application Job No 1333" ......

But how can I get the same string to concatenate and display correctly in
the "Subject" Field of the Hyperlink / new email, without resorting to
separate script?
It looks like ought to be possible but I just cannot make it work.
Any ideas?
If it is not possible - has anybody got a code snippet I could insert?

Help please

mike
 
G

Guest

Here is an example of a code snippet, you will need to include the outlook
refernce library.

The biggest problem with linking e-mails to outlook, are the various changes
Microsoft keep making to outlook in service packs, which tends to make the
whole process more difficult.

The following is fairly basic but should get you started.

Sub Mail_Send(Subject As String, Body As String, ToAddress As String,
DatabaseFile As String)
Dim objOL As Outlook.Application
Dim Trymail As Integer
Trymail = 0
RetryMail:
Trymail = Trymail + 1
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
MsgBox "Start Your EMail System The Press OK", vbInformation, "EMail
Not Running"
If Trymail > 5 Then
MsgBox "Aborting Operation Unable To Start E-Mail"
Exit Sub
End If
GoTo RetryMail
End If
On Error GoTo 0

Dim ObjFolder As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Set objNameSpace = objOL.GetNamespace("MAPI")
Call objNameSpace.Logon("Microsoft Outlook", "", False, True)
' Set ObjFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
' ObjFolder.Display
Set objMail = objOL.CreateItem(olMailItem)
objMail.Subject = Subject
objMail.Body = Body
objMail.To = ToAddress

objMail.Display

Set objOL = Nothing
End Sub

Hope this helps.
 
M

Michael J. Earl

Andy,

Thanks for the reply and code snippet....

But are you saying that I definitely can't set the subject in Href using
field information
eg.mailto:dfdfdhdhh@com?Subject=DataAccesssPages!MyDataAccessPage!Hypperlink
..text?

Please confirm

Mike

"Andy Couch - UK Access User Group"
 
G

Guest

No I am not saying that you definitely can't set the subject in Href using
field information, but you could try setting it via some code if you are
having problems with your current approach.

Hope this gives you another avenue to investigate.
 
M

Michael J. Earl

Looks like Href and Standard Hyperlink field settings can only parse
resolved, concatenated strings and one cannot use VB in Data Access Pages.
Instead one must use scripting or HTML and I'm totally out of my depth in
both.
I found some HTML code on the Knowledge Base - but I have to admit I don't
know where to start - I don't even know whereabouts in the HTML to insert
it.
So I think I'm stuck.
Put together with some unresolved e-commerce dynamic web site problems with
NetObjects Fusion 8, it's not been the most productive weekend.

But as they:- "If you have been, thanks for listening."

Mike


"Andy Couch - UK Access User Group"
 
G

Guest

Yea I probably directed you off in the wrong direction here. The kind of code
that I sent you would work in a standard access form, or work in ASP, or you
could get something similar to work in ASP.NET. I have a number of
applications which use ASP pages and Access databases for sophisticated
e-mailing, but I never use Data Access Pages, and would not recommend them
unless you have a very simple requirement, then they are too restrictive.

I remember seeing a sophisticated presentation on using Data Access pages,
and I kept thinking why bother, when their are much better technologies to
solve these problems.

My advise would be to use either .NET or standard ASP to achive your
functionality (as I presume you want it to work through a browser).

Sorry if I miss-directed you here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top