Results 1 to 13 of 13

Thread: Very simple emails from vb6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    Exclamation 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

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    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

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    Re: Very simple emails from vb6

    im using an access db with a vb front end

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    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:
    1. Private Sub cmdMailSend_Click()
    2.     Dim olapp As Object
    3.     Dim oitem As Object
    4.     Set olapp = CreateObject("Outlook.Application")
    5.     Set oitem = olapp.CreateItem(0)
    6.     With oitem
    7.         .Subject = "Test Email Using VB and Outlook Object"
    8.         .To = "YourEmail Address Here([email protected])"
    9.         .Body = "This message was sent from VB"
    10.         .Send
    11.     End With
    12.     Set olapp = Nothing
    13.     Set oitem = Nothing
    14.     Exit Sub
    15. End Sub
    Last edited by ricodstar; Jun 30th, 2005 at 07:11 AM.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    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?

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    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...?

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    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??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width