sending e-mail thru user form

A

Alex

On a page I have an e-mail (e-mail address removed) with hyperlink. But, I'd like to
give the user the opportunity to do the same thru a form.
I've created a userform with text boxes where the user can enter his/her
name, subject, and message then click button and send this message to the web
site (to (e-mail address removed) ).
How could I implement it thru VB?
I'm thinking about approx. the following code. But, in this code should I
know what e-mail program the user has on his computer or it will be the
server (website hosting) e-mail program and I shouldn't care about the user
e-mail program?

Dim OutApp As Object
Dim OutMail As Object

Set OutApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set OutApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set OutMail = OutApp.CreateItem(0)
.....
On Error Resume Next
With OutMail
.To = …
.CC = …
.Subject = …
.Body = …
.Send

End With
.....
Or I can use something else?

Thanks
 
E

Ed Bennett

Alex said:
On a page I have an e-mail (e-mail address removed) with hyperlink. But, I'd
like to give the user the opportunity to do the same thru a form.
I've created a userform with text boxes where the user can enter
his/her name, subject, and message then click button and send this
message to the web site (to (e-mail address removed) ).
How could I implement it thru VB?

Are you exporting the publication to a web page to get the links to be
active? If you are, no VB code will transfer.
Most users will want to use their own email client, really.
I'm thinking about approx. the following code. But, in this code
should I know what e-mail program the user has on his computer or it
will be the server (website hosting) e-mail program and I shouldn't
care about the user e-mail program?

If you use the code you mentioned, it will require Outlook. There is code
available by searching Google that allows you to send email from any VB
application. This, however, would not be appropriate in this instance.
 
Z

Zack Barresse

I'm very confused as to why you actually want to use a varible twice to set
it two different times.. Makes no sense to me. Are you wanting to use
Early or Late binding? You're showing signs of both. And as for what Ed
mentions, you do need to know what email app your clients are using. An
example of what you could use if you didn't know, is shown here ...

Word: http://vbaexpress.com/kb/getarticle.php?kb_id=310
Excel: http://vbaexpress.com/kb/getarticle.php?kb_id=311

The only difference being in the bottom portion of the code ...

Sub eMailActiveDocument()
Dim Doc As Document

Application.ScreenUpdating = False
Set Doc = ActiveDocument
Doc.Save

SendIt "(e-mail address removed)", "A new Document", "Hi, read this:", Doc.FullName

Application.ScreenUpdating = True
Set Doc = Nothing
End Sub.. and ..
Sub eMailActiveWorkbook()
Dim Wb As Workbook

Application.ScreenUpdating = False
Set Wb = ActiveWorkbook
Wb.Save

SendIt "(e-mail address removed)", "A new Document", "Hi, read this:", Wb.FullName

Application.ScreenUpdating = True
Set Wb = Nothing
End SubI believe the Word code should work for you in Publisher. (Ed,
please correct me if I'm wrong.)

HTH
 
E

Ed Bennett

Zack Barresse said:
And as for what Ed mentions, you do need to know what email app your
clients are using.

You can send email from a program without calling any external email
program. It's been a while since I've done it, but it's definitely
possible.
 
Z

Zack Barresse

Right. The links I posted are mailing without any email program using MAPI.
Personally, I make sure all my clients use Outlook and always use Late
Binding. It's just more trouble free that way, imho.

Hope all has been well with you Ed.
 

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