Send E-Mail from MSAccess using Groupwise

R

Robert_L_Ross

I've got a form called EMail in MSAccess that contains a field named
EMailToAddress. This field populates from a table of e-mail addresses.

On the EMail form, I have a subform (Messages) that has 2 fields (Subject
and Message).

On the main form (EMail) I have a button I want to use to send an e-mail to
the address specified on the EMail form (EMailToAddress) and that uses the
Subject and Message field contents from the subform.

Here's the code:
Private Sub EMail_Click()

Dim ToAddress, CCAddress, BCCAddress, Subject, MessageText As String

ToAddress = Forms!!EMailToAddress
CCAddress = "[email protected]"
BCCAddress = "[email protected]"
Subject = Forms![EMail]![Messages subform].Form![Subject]
MessageText = Forms![EMail]![Messages subform].Form![Message]

msg = MsgBox(ToAddress, vbOKOnly, "Test")

DoCmd.SendObject acSendForm, , acFormatTXT, ToAddress, CCAddress,
BCCAddress, Subject, MessageText, True

End Sub

My problem is the e-mail is generated with no "To" address, even though I
specify it by the variable ToAddress. I even tried putting the actual field
in the DoCmd.SendOjbect statement. The only way it populates that field is
if I set the varable value to "[email protected]" or place the actual e-mail in quotes in
teh DoCmd.SendObject statement.

Any ideas?
 
S

SA

Robert:

Have you stepped through your code using a break point and made sure the
value of the ToAddress is filled as a variable?

Also, if your Dim statement is a direct copy from your code, then note that
ToAddress, CC etc are all variants, not strings (although that shouldn't
make a difference), if you want them to be strings, you've go to write it
like this?

Dim ToAddress as String, CCAddress as String
Dim BCCAddressas String, Subject as String, MessageText As String

(Note if you want to try another method other than SendObject, try our PDF
and Mail Library which supports interface with GroupWise mail systems.)
 
R

Robert_L_Ross

Steve,

I added a msg line to check if the ToAddress variable captured the e-mail
address, and it did:
ToAddress = Forms!!EMailToAddress
msg = MsgBox(ToAddress, vbOKOnly, "Test")

It returned the correct e-mail address from the form, but it still didn't
place the e-mail in the To box in Groupwise.

I also modified the Dim statements as you suggested:
Dim ToAddress As String, CCAddress As String
Dim BCCAddress As String, Subject As String, MessageText As String

No change. BUT...

The record I was using as a test case had my own e-mail address for the To
address (so I could test it with my own e-mail account). When I use other
test records - even fake ones (i.e. [email protected]) it works fine.

I'm wondering if it's part of GroupWise, thinking I wouldn't send an e-mail
to myself so don't transfer your own e-mail into the To box?



[QUOTE="SA"]
Robert:

Have you stepped through your code using a break point and made sure the
value of the ToAddress is filled as a variable?

Also, if your Dim statement is a direct copy from your code, then note that
ToAddress, CC etc are all variants, not strings (although that shouldn't
make a difference), if you want them to be strings, you've go to write it
like this?

Dim ToAddress as String, CCAddress as String
Dim BCCAddressas String, Subject as String, MessageText As String

(Note if you want to try another method other than SendObject, try our PDF
and Mail Library which supports interface with GroupWise mail systems.)
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

[QUOTE="Robert_L_Ross"]
I've got a form called EMail in MSAccess that contains a field named
EMailToAddress. This field populates from a table of e-mail addresses.

On the EMail form, I have a subform (Messages) that has 2 fields (Subject
and Message).

On the main form (EMail) I have a button I want to use to send an e-mail
to
the address specified on the EMail form (EMailToAddress) and that uses the
Subject and Message field contents from the subform.

Here's the code:
Private Sub EMail_Click()

Dim ToAddress, CCAddress, BCCAddress, Subject, MessageText As String

ToAddress = Forms![EMail]!EMailToAddress
CCAddress = "[email protected]"
BCCAddress = "[email protected]"
Subject = Forms![EMail]![Messages subform].Form![Subject]
MessageText = Forms![EMail]![Messages subform].Form![Message]

msg = MsgBox(ToAddress, vbOKOnly, "Test")

DoCmd.SendObject acSendForm, , acFormatTXT, ToAddress, CCAddress,
BCCAddress, Subject, MessageText, True

End Sub

My problem is the e-mail is generated with no "To" address, even though I
specify it by the variable ToAddress. I even tried putting the actual
field
in the DoCmd.SendOjbect statement. The only way it populates that field
is
if I set the varable value to "[email protected]" or place the actual e-mail in quotes
in
teh DoCmd.SendObject statement.

Any ideas?[/QUOTE]
[/QUOTE]
 
Top