How can I write a code to notify someone through email that an error has occured in the program
Printable View
How can I write a code to notify someone through email that an error has occured in the program
Check out this tutorial on making a POP3 client: http://vbsquare.com/internet/pop/
Ewwwww.....Farsi-Burt......that's way too much to send a simple mail in the event of program error. :p
Just plop the 2 MAPI controls on your form. The following will send mail thru whatever legitimate mail application they have on their system.(I don't consider AOL legitimate <g>)
VB Code:
Private Sub Command1_Click() Const SESSION_SIGNON = 1 Const MESSAGE_COMPOSE = 6 Const ATTACHTYPE_DATA = 0 Const RECIPTYPE_TO = 1 Const RECIPTYPE_CC = 2 Const MESSAGE_RESOLVENAME = 13 Const MESSAGE_SEND = 3 Const SESSION_SIGNOFF = 2 'Open up a MAPI session: MAPISession1.Action = SESSION_SIGNON 'Point the MAPI messages control to the open MAPI session: MAPIMessages1.SessionID = MAPISession1.SessionID MAPIMessages1.Action = MESSAGE_COMPOSE 'Start a new message 'Set the subject of the message: MAPIMessages1.MsgSubject = "This is the subject." 'Set the message content: MAPIMessages1.MsgNoteText = "This is the mail message." 'Set the recipients - repeat for each, just INC RecipIndex MAPIMessages1.RecipIndex = 0 'First recipient MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line MAPIMessages1.RecipDisplayName = "[email protected]" 'e-mail name 'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts 'the recipient address in MapiMessages1.RecipAddress 'If the E-Mail name is not valid, a trappable error will occur. MAPIMessages1.Action = MESSAGE_RESOLVENAME 'Send the message: MAPIMessages1.Action = MESSAGE_SEND 'Close MAPI mail session: MAPISession1.Action = SESSION_SIGNOFF Unload Me End Sub
What if you want the email to go to a recipient that is not in the address book?