Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Lotus Notes VB code (yes, it works)

Hello all, I found the following VB code and I was hopeing if someone could
twick it for me?
1. I would like to instead of send out a spread sheet, attache a .txt file
to the message.
2. Pick up the email addressies if they were in colum A (To:) and B (CC:)
3. In colum C, pick up the text and put a message the will be in the body of
the email
4. In colum D, pick up the text and put a message in the subject line
5. In colum E & F have a folder path (S:\SUPPORT\CADTAR\CMS\0013) & attache
the "d0013mr.txt" file or if it can pick up file names ending in "mr"

Data (looks better in excel, around 150 lines)
A1 B1 C1 D1
E1 F1
To: CC: Body of message Subject line Path File
Important Monthly Fuel Surcharge Update
BAX Global Update for ARTHREX - 013847514 -
9727 S:\SUPPORT\CADTAR\CMS\9727 d9727ar.txt

VB Code

Option Explicit



Const EMBED_ATTACHMENT As Long = 1454


Const stPath As String = "C:\Documents and Settings\autpbg1\My
Documents\Attachments"


Const stSubject As String = "MR Fuel update - test maco"


Const vaMsg As Variant = "This is a test, file does not mean anthing." &
vbCrLf & _
"Let me when you get this."


Const vaCopyTo As Variant = "



Sub Send_Active_Sheet()



Dim stFileName As String

Dim vaRecipients As Variant



Dim noSession As Object

Dim noDatabase As Object

Dim noDocument As Object

Dim noEmbedObject As Object

Dim noAttachment As Object

Dim stAttachment As String



'Copy the active sheet to a new temporarily workbook.

With ActiveSheet

.Copy

stFileName = .Range("A1").Value

End With



stAttachment = stPath & "\" & stFileName & ".xls"



'Save and close the temporarily workbook.

With ActiveWorkbook

.SaveAs stAttachment

.Close

End With



'Create the list of recipients.

vaRecipients = ")



'Instantiate the Lotus Notes COM's Objects.

Set noSession = CreateObject("Notes.NotesSession")

Set noDatabase = noSession.GETDATABASE("", "")



'If Lotus Notes is not open then open the mail-part of it.

If noDatabase.IsOpen = False Then noDatabase.OPENMAIL



'Create the e-mail and the attachment.

Set noDocument = noDatabase.CreateDocument

Set noAttachment = noDocument.CreateRichTextItem("stAttachment")

Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "",
stAttachment)



'Add values to the created e-mail main properties.

With noDocument

.Form = "Memo"

.SendTo = vaRecipients

.CopyTo = vaCopyTo

.Subject = stSubject

.Body = vaMsg

.SaveMessageOnSend = True

.PostedDate = Now()

.Send 0, vaRecipients

End With



'Delete the temporarily workbook.

Kill stAttachment



'Release objects from memory.

Set noEmbedObject = Nothing

Set noAttachment = Nothing

Set noDocument = Nothing

Set noDatabase = Nothing

Set noSession = Nothing



MsgBox "The e-mail has successfully been created and distributed",
vbInformation



End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Lotus Notes VB code (yes, it works)

I have no idea how much can be shared across email clients, but Ron de Bruin has
tons of notes about emailing and excel he

http://www.rondebruin.nl/sendmail.htm



pgarcia wrote:

Hello all, I found the following VB code and I was hopeing if someone could
twick it for me?
1. I would like to instead of send out a spread sheet, attache a .txt file
to the message.
2. Pick up the email addressies if they were in colum A (To:) and B (CC:)
3. In colum C, pick up the text and put a message the will be in the body of
the email
4. In colum D, pick up the text and put a message in the subject line
5. In colum E & F have a folder path (S:\SUPPORT\CADTAR\CMS\0013) & attache
the "d0013mr.txt" file or if it can pick up file names ending in "mr"

Data (looks better in excel, around 150 lines)
A1 B1 C1 D1
E1 F1
To: CC: Body of message Subject line Path File
Important Monthly Fuel Surcharge Update
BAX Global Update for ARTHREX - 013847514 -
9727 S:\SUPPORT\CADTAR\CMS\9727 d9727ar.txt

VB Code

Option Explicit



Const EMBED_ATTACHMENT As Long = 1454

Const stPath As String = "C:\Documents and Settings\autpbg1\My
Documents\Attachments"

Const stSubject As String = "MR Fuel update - test maco"

Const vaMsg As Variant = "This is a test, file does not mean anthing." &
vbCrLf & _
"Let me when you get this."

Const vaCopyTo As Variant = "



Sub Send_Active_Sheet()



Dim stFileName As String

Dim vaRecipients As Variant



Dim noSession As Object

Dim noDatabase As Object

Dim noDocument As Object

Dim noEmbedObject As Object

Dim noAttachment As Object

Dim stAttachment As String



'Copy the active sheet to a new temporarily workbook.

With ActiveSheet

.Copy

stFileName = .Range("A1").Value

End With



stAttachment = stPath & "\" & stFileName & ".xls"



'Save and close the temporarily workbook.

With ActiveWorkbook

.SaveAs stAttachment

.Close

End With



'Create the list of recipients.

vaRecipients = ")



'Instantiate the Lotus Notes COM's Objects.

Set noSession = CreateObject("Notes.NotesSession")

Set noDatabase = noSession.GETDATABASE("", "")



'If Lotus Notes is not open then open the mail-part of it.

If noDatabase.IsOpen = False Then noDatabase.OPENMAIL



'Create the e-mail and the attachment.

Set noDocument = noDatabase.CreateDocument

Set noAttachment = noDocument.CreateRichTextItem("stAttachment")

Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "",
stAttachment)



'Add values to the created e-mail main properties.

With noDocument

.Form = "Memo"

.SendTo = vaRecipients

.CopyTo = vaCopyTo

.Subject = stSubject

.Body = vaMsg

.SaveMessageOnSend = True

.PostedDate = Now()

.Send 0, vaRecipients

End With



'Delete the temporarily workbook.

Kill stAttachment



'Release objects from memory.

Set noEmbedObject = Nothing

Set noAttachment = Nothing

Set noDocument = Nothing

Set noDatabase = Nothing

Set noSession = Nothing



MsgBox "The e-mail has successfully been created and distributed",
vbInformation



End Sub


--

Dave Peterson
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
Preset fields in Lotus Notes Code J.W. Aldridge Excel Programming 2 October 7th 07 05:46 AM
Mail über Lotus Notes aus Excel heraus/ Sending Mail with Excel through Lotus Notes [email protected] Excel Programming 0 February 19th 07 12:11 PM
Send Mail - Code to test whether Lotus Notes / Outlook is used Andibevan[_4_] Excel Programming 2 August 12th 05 03:10 PM
Ron, I found some code that works with Lotus Notes Tim Excel Programming 5 August 1st 05 03:12 PM
Can you use code to Send excel spreadsheets via Lotus Notes?? Belzeddar[_3_] Excel Programming 2 January 19th 04 11:05 PM


All times are GMT +1. The time now is 02:35 AM.

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

About Us

"It's about Microsoft Excel"