Solved

Send parameters to Ms Outlook

Posted on 2000-05-16
4
243 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now