CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 41
  1. #1
    Join Date
    Jan 2002
    Posts
    9

    sending e-mail through VB application

    Hi All,
    I am developing an application wherein I need to send one data report through the application to a specific e-mail address. How can I do it?

  2. #2
    Join Date
    Aug 2001
    Posts
    1,447
    The simplest code to send emails is this: (you need to have Outlook installed)

    Code:
    Dim objOutlook As Object
    Dim objOutlookMsg As Object
    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(0)
    With objOutlookMsg
       .To = "you@email.com
       .Cc = "ifneed@copy.com"
       .Subject = "Hello World (one more time)..."
       .Body = "This is the body of message"
       .HTMLBody = "HTML version of message"
       .Attachments.Add ("c:\myFileToSend.txt")
       .Send 'Let´s go!
    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    [Cimperiali: colored and indented for better reading
    Last edited by Cimperiali; May 15th, 2003 at 05:27 PM.
    phinds
    vs2008, 3.5SP1 Version 9.0.21022.8 RTM

  3. #3
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    2

    Question

    I have the same question. I tried this code and it works great. Thanx.
    But how do I get the location of the data report in order to attach it? I wasn't saving them, just creating them for printing purposes.

  4. #4
    Join Date
    Jan 2003
    Location
    Bangalore, INDIA
    Posts
    180
    But phinds

    when I tried the code I got an error like "ActiveX cannot create object..." at line 3

    Suhaib

  5. #5
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    Suhaib,

    That code automates the Microsoft Outlook Express, and it is required that you have the software installed in the machine.

    The best thing is to use winsock with SMTP protocol with a bit of MIME. Check the threads it was posted somewhere I just couldn't remember. Try searching the RFC's for SMTP as well as MIME, it's worth reading.

    Check this thread:
    http://www.codeguru.com/forum/showth...hreadid=232562
    Last edited by Thread1; February 28th, 2003 at 12:09 AM.
    Busy

  6. #6
    Join Date
    Mar 2001
    Posts
    6
    I think the really simplest way is to use VB's MAPI controls and BTW the code automates Outlook, too.
    Cheers,

    Frank

  7. #7
    Join Date
    Jan 2001
    Posts
    486
    My copy of VB6 contained a Sample of sending email through VB. Perhaps yours does too. I just defaulted all directories when installing VB and the location of that sample was placed at:

    C:\Program Files\Microsoft Visual Studio\MSDN\99OCT\1033\Samples\VB98\misc\Vbmail

    Maybe you can check your PC for same to get some hints.
    If kids were left to their own devices, would they ever come up with a thing like war?......The Wheel / Todd Rundgren

    Do canibals not eat clowns because they taste funny?

  8. #8
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Not Outlook Express but Outlook

    Originally posted by Thread1
    Suhaib,

    That code automates the Microsoft Outlook Express, and it is required that you have the software installed in the machine.
    A note: outlook.application is Outlook, not the express one. But what Thread1 said changes really few, as you must have outlook installed to make that code work..
    Last edited by Cimperiali; August 19th, 2003 at 09:42 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  9. #9
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    Thanks to Cimperiali for the correction..
    Busy

  10. #10
    Join Date
    Mar 2001
    Posts
    6

    Re: Not Outlook Express but Outlook

    Originally posted by Cimperiali
    A note: outlook.application is Outlook, not the express one. But what Thread1 said changes really few, as you must have outlook installed to make that code work..
    I'm not quite sure on this. But you just only need the Outlook *.olb file? to get this running?
    Cheers,

    Frank

  11. #11
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Five ways to send mail

    Look at attached txt

    '*********
    '* Reloaded
    '*********
    Attached Files Attached Files
    Last edited by Cimperiali; October 30th, 2003 at 07:30 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  12. #12
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    With outlook Express

    This is somethingh I found surfing the web
    Attached Files Attached Files
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  13. #13
    Join Date
    May 2002
    Location
    Montreal
    Posts
    450
    But you just only need the Outlook *.olb file? to get this running?
    I think you're right, but this are non-redistributable files, so technically, you have to have Outlook installed.

    Cimperiali: Wow, you're really going out of your way for us!! thank you very much for doing research for us and compiling the email code. Maybe those should be in the FAQ??
    Cheers,
    Laurent

    For an aviator, the three best things in life are a good landing, a good orgasm, and a good sh*t. A night carrier landing is one of the few opportunities to experience all three at the same time.

  14. #14
    Join Date
    Jul 2003
    Location
    Bahrain
    Posts
    3
    I know this might not be related, but I hope some one can help me. I'm using "phinds" code, with Outlook 2000 installed. Now when ever I try to send an e-mail, outlook gives me a message saying that a program is trying to send an email on your behafe bla bla and I have to click yes or no, I know this is a security function, but can it be disabled??? so that outlook will send the e-mail without giving that message?!

    Thanks and Regards,
    Boiling Ice

  15. #15
    Join Date
    May 2002
    Location
    Montreal
    Posts
    450
    This is a security patch that was introduced a while back with Win 2000 SP2 or Outlook 2000 SP2 or something like that. Couldn't find a way to get around it for now unless not using Outlook to send email.
    Cheers,
    Laurent

    For an aviator, the three best things in life are a good landing, a good orgasm, and a good sh*t. A night carrier landing is one of the few opportunities to experience all three at the same time.

Page 1 of 3 123 LastLast

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

Featured