Solved

global attacment running lotus notes

Posted on 2003-10-21
8
261 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now