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?
Printable View
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?
The simplest code to send emails is this: (you need to have Outlook installed)
[Cimperiali: colored and indented for better readingCode:Dim objOutlook As Object
Dim objOutlookMsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
.To = "[email protected]
.Cc = "[email protected]"
.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
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.
But phinds
when I tried the code I got an error like "ActiveX cannot create object..." at line 3 :(
Suhaib
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
I think the really simplest way is to use VB's MAPI controls and BTW the code automates Outlook, too.
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.
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..Quote:
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.
Thanks to Cimperiali for the correction..:cool:
I'm not quite sure on this. But you just only need the Outlook *.olb file? to get this running?Quote:
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..
Look at attached txt
'*********
'* Reloaded
'*********
This is somethingh I found surfing the web
I think you're right, but this are non-redistributable files, so technically, you have to have Outlook installed.Quote:
But you just only need the Outlook *.olb file? to get this running?
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??
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
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.