Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-Mail MAcro to be able to send form directly to me

Status
Not open for further replies.

Jack58

Technical User
Joined
May 6, 2002
Messages
91
Location
US
I have developed a form with a text field that upon exit the form is put into an e-mail as an attachment. Is their a way to automatically add my name and have the form auto send direct to me without the user needing to enter my name and click send?

Thanks in Advance



Jack
 
If you use an HTML FORM, the submit button will send it to your email address.

If you already have a FORM I think you know this, so perhaps more about why it does not work would help.
 
Saving the form as a Web (HTML) page works well for sending an e-mail directly to me, however I want to be able to send an e-mail with the form as an attachment.

I have already tried to create a Macro to send the form with attachments to me, however I do not know how to get the macro that was created to place my e-mail address directly into the To: section.



Thanks as always
 
I would suggest adding a command button labeled - SEND. This is usually better that coding the ON EXIT property of the last txtUSERINPUT box. ( And avoids them sending an incomplete form)

Now, here is the code I use in EXCEL to have supervisors email a worksheet directly to me. This is the VBA sub in tied to the the ON CLICK|EVENT PROCEDURE:

------Code Starts--------------------
Sub SendSheet()
X1 = Range("E1").Value
X2 = Range("H1").Value
Xf = Range("A65536").End(xlUp).Row

strRecipients = "YOUREMAIL@SOMECOMPANY.COM"
ActiveSheet.Copy
ActiveWorkbook.SendMail strRecipients, "Mo Stat Rpt: " & X2 & " from: " & X1
ActiveWorkbook.Close False

MsgBox "You have sent the " & X2 & " report to Brad via EMAIL", vbInformation, "Email Confirmation"

'Range("E" & (Xf + 1)).Value = "This report was Emailed to BRAD"


End Sub
---------snippet ends---------

Since you're working in WORD, you may want this code snippet. I used this in a vb application to have users email updates to me. It call the OUTLOOK object and can be used in an ON CLICK|EVENT PROCEDURE bound to a command button.

-----Code Starts----------------
Private Sub Email_Request()
'open Outlook and send me a pre-formatted email with update info
'create new message
Set objOutlk = CreateObject("Outlook.Application")
Set objMail = objOutlk.createitem(olMailItem)
objMail.To = "YOUREMAIL@SOMECOMPANY.COM"
objMail.subject = "Phone Book Update Request"
'add body
strMsg = "Last Name: " & vbCrLf
strMsg = strMsg & "First Name: " & vbCrLf
strMsg = strMsg & "What needs Corrected: " & vbCrLf & vbCrLf & vbCrLf & vbCrLf
strMsg = strMsg & "** Your request will be processed in the next" & vbCrLf
strMsg = strMsg & "update...please be patient...I update records" & vbCrLf
strMsg = strMsg & &quot;approx. twice a month. <Brad>**&quot;
objMail.body = strMsg
'this previews email prior to sending
objMail.display
'this send automatically
'objMail.display

Set objMail = Nothing
Set objOutlk = Nothing


End Sub
---------Snippet Ends-----------

HTH...Brad
P.S. These two snippets are modified from other code I found on the net...Props to the original authors...whoever they are.
 
Excellent, however I want to add an attachment to the e-mail. The current VBA code is only pulling information from a source. Can someone tell me how to add a attachment with a samll note to users of my form?

Again THANKS!!!!



Jack
 
Another DUMB Question,

What code do I need to write to use the command button with the above Event Procedure. I have done this several times before and am drawing a blank. hope someone can help me out.


Thanks!!!


Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top