Send email from access form

S

stockwell43

Hello,

I need some help with a piece of code from a database that someone else
worked on and now I am stuck with it. It has a button that when clicked will
pop up and email and it works fine and pulls the correct information from the
form. However, the problem I am having is the cursor start at the beginning
of the project name and I need it (manager wants it) to appear on the next
line after the project name but I can't seem to get it. If someone can please
help I would appreciate it.

Yes, I have posted this a couple of times but have not received a respond in
two days. Normally, I do not like to post twice as it is Inefficient.

Here is the code I am using:
Private Sub cmdEmail_Click()
On Error GoTo EH
Dim SendTo As String, SendCC As String, MySubject As String, MyMessage
As String
SendTo = Me.AssignedTo

MySubject = "Project Information"
MyMessage = Me.ProjectName & vbCr
DoCmd.SendObject acSendNoObject, , , SendTo, SendCC, SendBCC, MySubject,
MyMessage, True

EH:
If Err.Number = 2501 Then
MsgBox "This email message has not been sent. Message has been
cancelled."
End If
End Sub

Any help would be most appreciated!!!!!

Thanks!!!
 
J

Jon Lewis

The difficulty here (I think) is that SendObject opens the default email
editor in 'Dialog' mode so code execution within your procedure is halted
until Send is clicked or the dialog closed. Therefore trying to place your
cursor once the dialog has opened from code in the procedure won't work.
(Adding line breaks etc. to MyMessage doesn't seem to have any effect on the
cursor position).

If you want the desired behaviour then I think you will have to use
automation of the email app rather than SendObject to achieve this. There
is a library called CDO which should enable you to do this with Outlook.
Plenty of examples Googleable

HTH
 
A

Arvin Meyer MVP

If it can be done it is a function of the email program, not Access.
Depending upon your email program, you may be able to automate it from
Access. You need to ask this question in a newsgroup or forum dedicated to
your email client.
 

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

Similar Threads

Bold Code 2
Email Help 17
Email issue 0
Emailing from a form 0
Email problem 5
Email Issue 1
BCC Email 3
SendObject Email 2

Top