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 Submit Button

Status
Not open for further replies.

lucidity23

Programmer
Feb 14, 2001
99
US
I am trying to make a button which will e-mail an S Word form to certain e-mail addresses.

IS this possible?

If so...what is the best VB code to use for the button?

Any help is welcome...thanks!
- carpe diem -
 
If you are using Outlook, then I think this will work for you. In your project, set a reference to the Microsoft Outlook X.X Object Library (I have the Outlook 9.0 Object Library. Your may be a different version)

Then pop the following code into a sub routine, or the click event of a command button:

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim CallDescription As String

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(Who you are sending it to)
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("an other person")
objOutlookRecip.Type = olCC

.SentOnBehalfOfName = "Me Myself and I"

' Set the Subject, Body, and Importance of the message.
.Subject = "Replace this String With your subject"
.Body = "replace this String With your message

' Add attachments to the message.
If Not IsMissing("c:\path\documentname") Then
Set objOutlookAttach = .Attachments.Add("c:\path\documentname")
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Send
'if you wanted to display the message sending, you could do a .Display instead of a .Send
End With

Set objOutlook = Nothing

Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top