Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a .log file

Status
Not open for further replies.

Stella1209

Programmer
Feb 9, 2001
32
US
I have a VB application that sends an e-mail. My problem is when the recipient name in a database different from name in MS Outlook it will not send an e-mail to that person. What I want to accomplish is that I want to generate an error when this occurs and create a .log file that has a recipient name(who didn't get an e-mail) and date. I also want that .log file to be e-mailed to me. If you have any suggestions I would appreciate your help. Thanks in advance.

 
Maybe You don't have to use it.

Try this:

NewTo.ResolveAll

where NewTo is a Recipients type variable. This should resolve the differences bit what Otlook nows and where You want to send the message.

My advise: use the MAPI controls to send mail. It's not limited to the Outlook!!! With MAPI You can send even fax messages!

If You need example: tiborpalko@hotmail.com
 
1127,

Thanks for your response.

I am using a crystal report properties to send an e-mails.

CrystalReport1.PrintFileType = crptText
CrystalReport1.Destination =crptMapi
CrystalReport1.EMailToList = strEmail (variable that hold all recipient names)
CrystalReport1.PrintReport

My question: Is NewTo.ResolveAll that you mentioned before will work with it?


Thanks a lot,
Stella

 
Hi,

No.

My suggestion: export the report to a file and use the MAPI controls to send the mail. You even can build an object that send a mail, and reuse it in other applications.

Tibi
 
Tibi,

Do you have a sample application with Mapi controls that I can see?

Actually, I am exporting a report to a text file,and sending it as an attachment, but I would like to see a sample program that sending an e-mail using Mapi controls.

Thanks,

Stella
 
Public Function SendThis(strSubject As String, strBody As String, strFileName As String) As Boolean

With <FormName>.Controls(<The MAPISession Control name>) 'the form name is where You place the MAPISession
' Set DownLoadMail to False to prevent immediate download.
.DownLoadMail = 0
.LogonUI = -1 ' Use the underlying email system's logon UI.
.SignOn ' Signon method.
.NewSession = -1
<FormName>.Controls(<The MAPIMessage Control name>).SessionID = .SessionID ' You must set this before continuing.
End With

With <FormName>.Controls(<The MAPIMessage Control name>)
.Compose
.MsgIndex = -1 '.MsgCount - 1
.RecipIndex = .RecipCount
.RecipType = 1
.RecipAddress = <The mail address(es)>
.ResolveName
.MsgSubject = strSubject
.MsgNoteText = strBody
.AttachmentIndex = .AttachmentCount
.AttachmentType = 0
.AttachmentName = &quot;&quot;
.AttachmentPathName = strFileName 'File name with full path
.Send '-1
SendThis = -1
End With
<FormName>.Controls(<The MAPISession Control name>).SignOff
Exit Function

errLogInFail:
Select Case Err.Number
Case 32003
MsgBox &quot;Conection Canceled!&quot;, vbCritical
Case 32001
MsgBox &quot;Canceled by User!&quot;, vbExclamation
Case Else
MsgBox Err.Number & &quot; &quot; & Err.Description & vbNewLine & &quot;Please note this number and text and send it to programmer!&quot;, vbCritical
End Select
<FormName>.Controls(<The MAPISession Control name>).SignOff
SendThis = 0
Exit Function
End Function

Whatch out the <> symbols means You have to insert the stuff!!
You may have some diff! tiborpalko@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top