Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Array of files

This code I found somewhere on the net and it works a treat for sending
one attachment to multiple recipients within a Lotus Notes environment.

It would be more practical to have the email names in Col A and have it
send more than one attachment with the corresponding file name and path
in Col B. I have to send out about 10 different attachments. Is this
possible with an array of some sort? Any help would be most
appreciated as I am all searched out and I usually find what I am
after.

Thanks

Chad


Sub SendLotusNote()

' be sure to reference the Lotus Domino Objects, domobj.tlb
Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesDocument As Object
Dim objAttachment As Object
Dim objRichText As Object
Dim FullPath As String
Dim FileName As String
Dim Msg As String

Const EMBED_ATTACHMENT = 1454

Set objNotesSession = CreateObject("Notes.Notessession")
Set objNotesDatabase = objNotesSession.GetDatabase("*", "")
Call objNotesDatabase.OpenMail 'default mail database
If objNotesDatabase.IsOpen = False Then
MsgBox "Cannot connect to Lotus Notes."
Exit Sub
End If
Set objNotesDocument = objNotesDatabase.CreateDocument
Call objNotesDocument.ReplaceItemValue("Form", "Memo")
ActiveWorkbook.Save
FullPath = Range("B1").Value ' file to send lives here
' assemble message
Set objRichText = objNotesDocument.CreateRichTextItem("Body")
Set objAttachment = objRichText.EmbedObject(EMBED_ATTACHMENT, "",
FullPath)
Msg = "Lotus Note sent from " & objNotesSession.CommonUserName
With objNotesDocument
.Subject = ""
.body = Msg
.SendTo = ", ",
")
.SaveMessageOnSend = True ' save in Sent folder
.Send (False)
End With

Set objNotesSession = Nothing
Set objNotesDatabase = Nothing
Set objNotesDocument = Nothing
Set objAttachment = Nothing
Set objRichText = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Array of files

Suggestion

Change

.SendTo = ", ")

to

Dim aryAddys()

aryAddys = Range("A1:A100")
.SendTo = aryAddys

may not work as it is a 2d array, but I cannot test it.


--
HTH

Bob Phillips

"Chad" wrote in message
ups.com...
This code I found somewhere on the net and it works a treat for sending
one attachment to multiple recipients within a Lotus Notes environment.

It would be more practical to have the email names in Col A and have it
send more than one attachment with the corresponding file name and path
in Col B. I have to send out about 10 different attachments. Is this
possible with an array of some sort? Any help would be most
appreciated as I am all searched out and I usually find what I am
after.

Thanks

Chad


Sub SendLotusNote()

' be sure to reference the Lotus Domino Objects, domobj.tlb
Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesDocument As Object
Dim objAttachment As Object
Dim objRichText As Object
Dim FullPath As String
Dim FileName As String
Dim Msg As String

Const EMBED_ATTACHMENT = 1454

Set objNotesSession = CreateObject("Notes.Notessession")
Set objNotesDatabase = objNotesSession.GetDatabase("*", "")
Call objNotesDatabase.OpenMail 'default mail database
If objNotesDatabase.IsOpen = False Then
MsgBox "Cannot connect to Lotus Notes."
Exit Sub
End If
Set objNotesDocument = objNotesDatabase.CreateDocument
Call objNotesDocument.ReplaceItemValue("Form", "Memo")
ActiveWorkbook.Save
FullPath = Range("B1").Value ' file to send lives here
' assemble message
Set objRichText = objNotesDocument.CreateRichTextItem("Body")
Set objAttachment = objRichText.EmbedObject(EMBED_ATTACHMENT, "",
FullPath)
Msg = "Lotus Note sent from " & objNotesSession.CommonUserName
With objNotesDocument
.Subject = ""
.body = Msg
.SendTo = ", ",
")
.SaveMessageOnSend = True ' save in Sent folder
.Send (False)
End With

Set objNotesSession = Nothing
Set objNotesDatabase = Nothing
Set objNotesDocument = Nothing
Set objAttachment = Nothing
Set objRichText = Nothing

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Array of files

Bob Phillips wrote:
Suggestion

Change

.SendTo = ", ")

to

Dim aryAddys()

aryAddys = Range("A1:A100")
.SendTo = aryAddys

may not work as it is a 2d array, but I cannot test it.


aryAddys = Application.Transpose(Range("A1:A100")) will produce a 1-D array

Alan Beban
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Array of files

Hi

Thanks this works perfectly. I can now have as many email addresses as
I wish attaching a single file. I tried to alter the code to have an
array refer to the corresponding file in Col B so I can attach multiple
files but it has been failing. Is there something obviously wrong with
the code?

Thanks

Chad

Sub SendLotusNote()

' be sure to reference the Lotus Domino Objects, domobj.tlb
Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesDocument As Object
Dim objAttachment As Object
Dim objRichText As Object
Dim FullPath As String
Dim FileName As String
Dim Msg As String
Dim aryAddys()
Dim myAry()

Const EMBED_ATTACHMENT = 1454

Set objNotesSession = CreateObject("Notes.Notessession")
Set objNotesDatabase = objNotesSession.GetDatabase("*", "")
Call objNotesDatabase.OpenMail 'default mail database
If objNotesDatabase.IsOpen = False Then
MsgBox "Cannot connect to Lotus Notes."
Exit Sub
End If
Set objNotesDocument = objNotesDatabase.CreateDocument
Call objNotesDocument.ReplaceItemValue("Form", "Memo")
ActiveWorkbook.Save
'Following 2 lines holt code.
myAry = Range("B1:B100")
FullPath = myAry 'does not like this.
' FullPath = Range("A1").Value '(original C wks fine)
' assemble message
Set objRichText = objNotesDocument.CreateRichTextItem("Body")
Set objAttachment = objRichText.EmbedObject(EMBED_ATTACHMENT, "",
FullPath)
Msg = "Lotus Note sent from " & objNotesSession.CommonUserName
With objNotesDocument
.Subject = ""
.body = Msg
aryAddys = Range("B1:B100")
.SendTo = aryAddys
.SaveMessageOnSend = True ' save in Sent folder)
.Send (False)
End With

Set objNotesSession = Nothing
Set objNotesDatabase = Nothing
Set objNotesDocument = Nothing
Set objAttachment = Nothing
Set objRichText = Nothing

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Array of files

I think you would need to loop reading all files and embedding them one at a
time.

--
HTH

Bob Phillips

"Chad" wrote in message
ups.com...
Hi

Thanks this works perfectly. I can now have as many email addresses as
I wish attaching a single file. I tried to alter the code to have an
array refer to the corresponding file in Col B so I can attach multiple
files but it has been failing. Is there something obviously wrong with
the code?

Thanks

Chad

Sub SendLotusNote()

' be sure to reference the Lotus Domino Objects, domobj.tlb
Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesDocument As Object
Dim objAttachment As Object
Dim objRichText As Object
Dim FullPath As String
Dim FileName As String
Dim Msg As String
Dim aryAddys()
Dim myAry()

Const EMBED_ATTACHMENT = 1454

Set objNotesSession = CreateObject("Notes.Notessession")
Set objNotesDatabase = objNotesSession.GetDatabase("*", "")
Call objNotesDatabase.OpenMail 'default mail database
If objNotesDatabase.IsOpen = False Then
MsgBox "Cannot connect to Lotus Notes."
Exit Sub
End If
Set objNotesDocument = objNotesDatabase.CreateDocument
Call objNotesDocument.ReplaceItemValue("Form", "Memo")
ActiveWorkbook.Save
'Following 2 lines holt code.
myAry = Range("B1:B100")
FullPath = myAry 'does not like this.
' FullPath = Range("A1").Value '(original C wks fine)
' assemble message
Set objRichText = objNotesDocument.CreateRichTextItem("Body")
Set objAttachment = objRichText.EmbedObject(EMBED_ATTACHMENT, "",
FullPath)
Msg = "Lotus Note sent from " & objNotesSession.CommonUserName
With objNotesDocument
.Subject = ""
.body = Msg
aryAddys = Range("B1:B100")
.SendTo = aryAddys
.SaveMessageOnSend = True ' save in Sent folder)
.Send (False)
End With

Set objNotesSession = Nothing
Set objNotesDatabase = Nothing
Set objNotesDocument = Nothing
Set objAttachment = Nothing
Set objRichText = Nothing

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Having some problems linking an array across excel files Sage Excel Discussion (Misc queries) 1 March 8th 06 11:49 PM
Best way to import fixed-width delimited text files into an array? KR Excel Programming 1 March 3rd 05 02:40 PM
Basic Q: Field/Array info when importing fixed-width text files KR Excel Programming 0 March 1st 05 09:02 PM
Adding files to an array using Dir Jeff Excel Programming 17 January 31st 05 08:58 PM


All times are GMT +1. The time now is 03:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"