|
-
May 29th, 2009, 02:21 AM
#1
Thread Starter
New Member
Auto generation of Email with Attachments
Hi all,
am using VB6.0 with oracle as back end and Crystal report as report generator. Now our client requirment is while booting the server some report needs to be automatically generated and posted to customer via email in certain period of time regularly.
i tried it with several codings but not able to do it. Plz any one help me ASAP. its very urgent.
1. automatic execution of exe file to generate reports
2. automatic generation of email while booting
thank you
bala
-
May 29th, 2009, 02:48 AM
#2
Hyperactive Member
Re: Auto generation of Email with Attachments
1) In my sig is a link "Run on startup", that explains how to have your program auto-start when Windows does.
2) This page is a very in-depth tutorial on using crystal reports in vb6.
3) You didn't specify how you want to send the emails (you have to pick an email program, like Outlook, AOL, etc). You can have your program connect to an SMTP server via winsock or CDO.message, and send it that way, or you can have it try to use whatever the default email client is with:
vb Code:
ShellExecute 0, vbNullString, "mailto:" & sEmail, vbNullString, vbNullString, vbNormalFocus
But that method makes it more difficult to auto-populate the fields, which would mean it would require user interaction to send the mails, which I assume you don't want to do. If you want to use Outlook (which is the most common email program) you can use:
vb Code:
' Generate and send E-mail Set olOutlookApp = GetObject(, "Outlook.Application") If Err <> 0 Then ' Outlook not running - start it Set olOutlookApp = CreateObject("Outlook.Application") blnNewOutlookApp = True End If ' Create E-mail Set olEMail = olOutlookApp.CreateItem(olMailItem) With olEMail .To = "Stephen Jones; John Smith" .Subject = "Repair Item - Request for Inspection" .Body = "Please carry out the attached inspection request as soon as possible." .Attachments.Add ActiveDocument.FullName, olByValue, , "Inspection Request" .Send End With
That's about as best an answer as I can give with your post as vague as it is.
Good luck!
Last edited by deathfxu; May 29th, 2009 at 02:57 PM.
-
May 29th, 2009, 04:06 AM
#3
Re: Auto generation of Email with Attachments
if the server is booted but not logged in, as in auto start on AC back, or the person pushing the start button does not have enough privileges to login to server, your app may need to run as a service, there is also provision for task scheduler to run tasks at boot, without login
if the server does not have outlook installed, look at using CDO.message to send emails, plenty of examples in this forum, my choice to use in any case, can work with attachments, or vbsendmail
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|