Solved

global attacment running lotus notes

Posted on 2003-10-21
8
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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