Solved

Send parameters to Ms Outlook

Posted on 2000-05-16
4
246 Views
Last Modified: 2008-02-20
In a vb prog, I have to, from, subject and message textboxes.

If I press the button, this vb prog will bring up Ms Outlook and send
contents from those textboxes into
the fields in Ms Outlook. How do I do that ?
0
Comment
Question by:sing_web
  • 2
  • 2
4 Comments
 

Expert Comment

by:Bebeirken
ID: 2816014
You could try something like this :

Set vMail as Outlook.Mailitem

vmail.subject = txtsubject.text
vmail.to = txtto.text
vmail.from = txtfrom.text
vmail.body  = txtbody.text

vmail.send

I think it should work.

0
 

Accepted Solution

by:
Bebeirken earned 50 total points
ID: 2816876
I've been working on it some more and this seems to work :

dim vMail as clsmessage

Set vMail = New clsMessage
 vMail.Subject = 'subject text
 vMail.Body = 'Body text
 vMail.HeaderTo =  'email            
 vMail.Send
Set vMail = Nothing


The clsmessage looks as follows :


Public HeaderTo As String
Public HeaderFrom As String
Public Subject As String
Public Body As String

Private mMail As Outlook.MailItem
Private mOutlook As Outlook.Application

Public Sub Send()
    mMail.To = HeaderTo
    mMail.Subject = Subject
    mMail.Body = Body
   
    mMail.Send
End Sub

Public Property Get MailItem() As Outlook.MailItem
    Set MailItem = mMail
End Property

Public Property Set MailItem(aMailItem As Outlook.MailItem)
    Set mMail = aMailItem
End Property

Public Property Get Attachments() As Outlook.Attachments
    Set Attachments = mMail.Attachments
End Property

Public Property Set Attachments(aAttachments As Outlook.Attachments)
    Set mMail.Attachments = aAttachments
End Property

Private Sub Class_Initialize()
    Set mOutlook = New Outlook.Application
    Set mMail = mOutlook.CreateItem(olMailItem)
End Sub

Private Sub Class_Terminate()
    Set mMail = Nothing
    Set mOutlook = Nothing
End Sub

You will probably not need all of this. It seems to work just fine.
0
 

Author Comment

by:sing_web
ID: 2818315
What if I just want the field to be
copied and pasted into the Ms Outlook,
and not send the mail right away ?
0
 

Author Comment

by:sing_web
ID: 2818328
What if I just want the field to be
copied and pasted into the Ms Outlook,
and not send the mail right away ?

>> So, I can type the body by myself,
   but the to, from and subject are  
   pasted.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question