Solved

global attacment running lotus notes

Posted on 2003-10-21
8
270 Views
Last Modified: 2013-12-25
Could you please help!!!!!!

I am using the following codes to send mail and it is working fine
as long as I hard code the attachment file and e_mail address in the macro as you see (where is not desirable any more)

Question

Question1-How can I use it as a global attachment for example
Call oItem.EmbedObject(1454, "", "c:\data\*.xls")

Question2- What modification I need to do in my macro for following data file to sent each report to a address (Example send  *Q4-2003-all.xls to manager@hotmail and
*Q4-2003-customer to teamleader@hotmail.com and *Q4-2003-Errors.xls to sale@hotmail.com)

custAB Q4-2003-All.xls    custAB Q4-2003-Customer.xls   custAB Q4-2003-Errors.xls



Sub sendmail_to()
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean

Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")

If Not flag Then
    MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
    GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building Message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = " This is subject " 
oDoc.sendto = "customerAB@hotmail.com"
oDoc.Body = "This is the body of the mail"
oDoc.postdate = Date

'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "c:\data\custAB Q4-2003-All.xls")
Call oItem.EmbedObject(1454, "", "c:\data\custAB Q4-2003-Customer.xls")
Call oItem.EmbedObject(1454, "", "c:\data\custAB Q4-2003-Errors.xls")
oDoc.visable = True
'Sending Message
oDoc.Send False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
          If Err.Number = 7225 Then
          MsgBox "File doesn't exist"
          Else
          MsgBox Err.Number & " " & Err.Description
          End If
On Error GoTo exit_SendAttachment
End Sub
0
Comment
Question by:melindaj
  • 3
  • 3
8 Comments
 
LVL 8

Expert Comment

by:ampapa
ID: 9597698
Try changing:

Call oItem.EmbedObject(1454, "", "c:\data\custAB Q4-2003-All.xls")

To:

attachment = "c:\data\custAB Q4-2003-All.xls"
Call AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
0
 

Author Comment

by:melindaj
ID: 9604694
I belief your are answering only my question1 if is so
I have modify the program but it produce Error 424 object require
do you have any suggestion
0
 
LVL 8

Accepted Solution

by:
ampapa earned 21 total points
ID: 9605525
Did you get the error on the line that I gave you?

The object "AttachME" should have been "oItem", sorry.

attachment = "c:\data\custAB Q4-2003-All.xls"
Call oItem.EMBEDOBJECT(1454, "", Attachment, "Attachment")

You'll need to create a loop for your e-mail addresses as opposed to your setup where you are establishing your mail to address and  the document. Your setup will create an e-mail to a single person with three attachments as opposed to an e-mail to 3 indivisuals with a single attachment.

...
'Building Message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = " This is subject " 
oDoc.sendto = "customerAB@hotmail.com"
...

If you want to increase the points I'd be glad to be a little more direct...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:melindaj
ID: 9611743
To be honest with you I am not a programmer and I need more help but that is beside the point.
I have tried your codes yes it attached a file. as well as my macro if I provide a full path name of the file name( I WANT TO AVOID TYPE THE FULL PATH NAME AND FILE NAME) then send the file as per file extension as you see in question2

Question2- What modification I need to do in my macro for following data file to sent each report to a address (Example send  *Q4-2003-all.xls to manager@hotmail and
*Q4-2003-customer to teamleader@hotmail.com and *Q4-2003-Errors.xls to sale@hotmail.com)

custAB Q4-2003-All.xls    custAB Q4-2003-Customer.xls   custAB Q4-2003-Errors.xls



To answer to your question  NO I do not know how to create loop to do the job PLEASE SHOW ME your code. and even I do not know how to
implement your codes with in my macro code

0
 
LVL 8

Expert Comment

by:ampapa
ID: 10347889
Seems like the questioner was asking for a lot for 21 points and I think I gave them 21 points worth of an answer, I recommend not deleting the question and awarding me the points.

Just my opinion.
0
 

Author Comment

by:melindaj
ID: 10762288
This question have been answred by ampapa please PAQ
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question