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.
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.
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.
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:
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.
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?
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.
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.
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.
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?!
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.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.