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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Second call to cc:mail sends mail back to me

Status
Not open for further replies.
Aug 21, 2002
4
0
0
GB
I am using Outlook automation to send messages through cc:mail. This works fine when the first message is produced, but the second message gets sent to myself, and the attached file becomes a blank spreadsheet.

I have stepped through the code, and confirmed that the mail item is receiving the correct recipient, attachment etc., but can't work out why the mail is failing.

Can someone help me, either with this specific problem, or how to automate cc:mail any other way (without being asked every time to choose a profile - the problem I had using MAPI)

[afro2]
 
I seem to have solved it - the code I was using did not set every object to nothing after running, and was using public object variables. By setting the mail item and the MAPI folder to = Nothing, the problem is resolved.
[afro2][afro2]
 
GingerSteve:
I seem to have a similar issue. I have an app that uses Outlook email. It works fine when installed on PCs runningn Outlook.

My question is should it work when installed on PCs running Lotus Notes cc:Mail? Shouldn't the Outlook DLL (outlctl.dll) and Outlook object library (msoutl9.olb) references be sufficient to make it connect to the local email system?

This is kind of how the call is made in the program, and the corresponding subroutine!

Just want to know if it can be done... before trying to install on a cc:Mail machine!

'-- CALL THE EMAIL PROCESS AND SEND IT THE USER SPECIFIED/DEFAULT PARAMETERS

SendMyReport SendTo, SendCc, SendSubject, SendMessage, G_PDF_FILE

Private Sub SendMyReport(Recipient As String, CC As String, Subject As String, Body As String, Attach As String)
On Error GoTo ErrHandler
Dim objOL As New Outlook.Application
Dim objMail As MailItem

'-- CREATE A NEW MAIL ITEM
Set objMail = objOL.CreateItem(olMailItem)

With objMail
'-- SET THE RECIPIENTS
.To = IIf(Recipient <> &quot;&quot;, Recipient, &quot;&quot;)
'-- SET THE CC
.CC = IIf(CC <> &quot;&quot;, CC, &quot;&quot;)
'-- SET THE SUBJECT
.Subject = IIf(Subject <> &quot;&quot;, Subject, &quot;&quot;)
'-- SET THE BODY
.Body = IIf(Body <> &quot;&quot;, Body, &quot;&quot;)
'-- CHECK FOR ATTACHMENT
If Attach <> vbNullString Then
'-- ADD ATTACHMENT
.Attachments.Add Attach
End If
'-- SEND IT
.Send
End With

'-- CLEAN UP MEMORY
Set objMail = Nothing
Set objOL = Nothing


ErrHandler:
'MsgBox &quot;Error &quot; & Err.Number & &quot; &quot; & CStr(Err.Description) & &quot; &quot; & CStr(Err.Source)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top