Very simple emails from vb6
In my application i need to have the facility to sedn a smiple email to a team leader regrading the booking of time off by an adviser. The email client to be used is outlook and all the poeple on the network are conatced by ther full names. i want to have a form which has hidden boxes whihc conatin the recipents name based on a previous query (this has all gone ok) now I just need a simple bit of code that sends a simple message.. "adviser booked timer off" follwoed by the dates taken from 2 text boxes on the from. It then needs to send the email just using outlook.. its not nessasary to see outlook at all as it will be running in the background of every users pc. When i built the mock up in access it simply used the send to command but this is giving me real hastle.. i keep finding examples but they all seem to complex.. i need something very very simple... if anyone can point me in the right direction..
sean
Re: Very simple emails from vb6
You don't actually have to use Outlook to send the emails. Search the forums, this question has been asked many a time..If nothing satisfies, Planet Source Code is chock full of Email examples.
chem
Re: Very simple emails from vb6
Use Outlook from VB is no more complicated than using Word or Excel from VB. Are you doing this project in VB or Access VBA?
Re: Very simple emails from vb6
im using an access db with a vb front end
Re: Very simple emails from vb6
In your first post, you said that you had seen examples of using Outlook, so I think it would be redundant to post one as whatever I would post would doubtless mirror what you have already seen.
So, let me ask, what is it about the examples that you find 'complex'? Perhaps we can straighten the issues out a little and simplify things.
Re: Very simple emails from vb6
ive tried simple ones but i get errors saying activex cannot open outlook.. ive deleted the code now so i cant remember exactly.. im trtying a piece of code from planet source code now so ill see what happens and ill post thye code so others can see
Re: Very simple emails from vb6
Ok i tried using this code but i get the error 2run time 429, activex component cant create object??
VB Code:
Private Sub cmdMailSend_Click()
Dim olapp As Object
Dim oitem As Object
Set olapp = CreateObject("Outlook.Application")
Set oitem = olapp.CreateItem(0)
With oitem
.Subject = "Test Email Using VB and Outlook Object"
.Body = "This message was sent from VB"
.Send
End With
Set olapp = Nothing
Set oitem = Nothing
Exit Sub
End Sub
Re: Very simple emails from vb6
Your code worked fine for me.
I believe your problem is that you need to set a reference to the Microsoft Outlook Object Library.
Try that, and then rerun your code.
Re: Very simple emails from vb6
ive got microsoft outlook 11.0 objetc libary referenced and it still wont work? does it have anything to do with where outlook is saved on my pc?
Re: Very simple emails from vb6
It shouldn't.
I put together a sample project using your code that works on my PC. I used my own EMail address in the .To part, and then changed it back to the sample after I received the mail message.
I'm attaching it. Modify it to use your email address and see what happens.
Re: Very simple emails from vb6
Hi ive just tried it and i get the same issue... could it be to do with outlook on my pc...?
Re: Very simple emails from vb6
Here is a simple email that works with this ISP. You could use any smtp host that you want, but this one was working for me even a few weeks ago.
http://vbforums.com/attachment.php?attachmentid=37741
Re: Very simple emails from vb6
Ok, im trying to write a line of code that says an advsier on your team has booked time off the details are as follows:" name = text2, date from = text3 and date until = text4,
The results are to be sent in an email but i cant get this string write, below is how i tried to write it:
Code:
.body = "An adviser on yout team has tried to book time off, the details are below:" and "Name" = text2.text and "Date from" = text3.text and "Date Until" = text4.text
any ideas??