Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Closing and attaching spreadsheet to an email


Hi,

I have a hyperlink (email address) in a user form, but what I would
like to do is when the link is clicked, the file to get attached to an
email.

Here is the code I presently have, where by clicking will open an email
window and the file wil remain open.

Private Sub lblMail_Click()
Link = "
ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True
Unload Me

Exit Sub

End Sub


Private Sub UserForm_Click()


End Sub

Appreciate your help.

Mike


--
caddy
------------------------------------------------------------------------
caddy's Profile: http://www.excelforum.com/member.php...o&userid=31858
View this thread: http://www.excelforum.com/showthread...hreadid=515843

  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Closing and attaching spreadsheet to an email

What e-mail client do you have on your comp?

--
Hmm...they have the Internet on COMPUTERS now!


"caddy" wrote:


Hi,

I have a hyperlink (email address) in a user form, but what I would
like to do is when the link is clicked, the file to get attached to an
email.

Here is the code I presently have, where by clicking will open an email
window and the file wil remain open.

Private Sub lblMail_Click()
Link = "
ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True
Unload Me

Exit Sub

End Sub


Private Sub UserForm_Click()


End Sub

Appreciate your help.

Mike


--
caddy
------------------------------------------------------------------------
caddy's Profile: http://www.excelforum.com/member.php...o&userid=31858
View this thread: http://www.excelforum.com/showthread...hreadid=515843


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Closing and attaching spreadsheet to an email


lotus notes


--
caddy
------------------------------------------------------------------------
caddy's Profile: http://www.excelforum.com/member.php...o&userid=31858
View this thread: http://www.excelforum.com/showthread...hreadid=515843

  #4   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default Closing and attaching spreadsheet to an email

Ick. (Though I'm in the same boat - I recently changed jobs from a company
that used Outlook to one that uses Lotus.)

I've never done it myself, but here is some *untested* code I found on this
NG.

Sub testSendMail()
Dim bOK As Boolean
bOK = sendNotesMail(Range("Subject"), Range("Attachment"),
Range("Recipient"), Range("BodyText"), Range("SaveIt"))
MsgBox "sent: " & CStr(bOK)
End Sub


Function sendNotesMail(Subject As String, attachment As String, recipient As
String, bodytext As String, SaveIt As Boolean) As Boolean
Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim AttachME As Object
Dim session As Object
Dim EmbedObj As Object


On Error GoTo err_SendNotesMail


'Start a session to notes
Set session = CreateObject("Notes.NotesSession")


'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = session.UserName
MailDbName = Mid$(UserName, 4, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"


'Open the mail database in notes
Set Maildb = session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OpenMail
End If


'Set up the new mail document
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
MailDoc.sendTo = recipient
MailDoc.Subject = Subject
MailDoc.Body = bodytext
MailDoc.SaveMessageOnSend = SaveIt


'Set up the embedded object and attachment and attach it
If attachment < "" And Dir(attachment) < "" Then
Set AttachME = MailDoc.CreateRichTextItem("Attachment")
Set EmbedObj = AttachME.EmbedObject(1454, "", attachment, "Attachment")
'MailDoc.CREATERICHTEXTITEM ("Attachment")
End If


'Send the document
MailDoc.Send 0, recipient
Maildb.Close
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set session = Nothing
Set EmbedObj = Nothing
sendNotesMail = True


end_SendNotesMail:
Exit Function


err_SendNotesMail:
Select Case Err.Number
Case 429:
MsgBox "Error: " & vbCrLf & Err.Description & vbCrLf & "Possible
cause:" & vbCrLf & "Lotus Notes not installed", vbCritical, "Error
whileinitializing LotusNotes"
Case Else:
MsgBox Err.Description & Err.Number, vbCritical, "Error Lotus Notes
Mail"
End Select
Resume end_SendNotesMail
End Function


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")


Do ' prompt user for file name and location
FullPath = Application.GetSaveAsFilename
Loop Until FullPath < False
' save to new loc; Lotus only sends last-saved copy
ActiveWorkbook.SaveAs FullPath
FileName = ActiveWorkbook.Name


' assemble message
Set objRichText = objNotesDocument.CreateRichTextItem("Body")
Set objAttachment = objRichText.EmbedObject(EMBED_ATTACHMENT, "",
FullPath, FileName)
Msg = "Lotus Note sent from " & objNotesSession.CommonUserName
With objNotesDocument
.Subject = "Excel Lotus Note!"
.Body = Msg
.sendTo = "lotus.mailbox"
.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


MsgBox "Your Lotus Notes message was successfully sent"
ActiveWorkbook.Close


End Sub


Sub EMail()
'You will also need to reference 'Notes32.tlb' in your project.
Dim session As Object
Dim db As Object
Dim doc As Object


Set session = CreateObject("Notes.NotesSession")
Set db = session.GETDATABASE("Your Domino Server", "Your Mail Database")
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.Subject = "VB App Test " & Now()
doc.Body = "VB App Test. Sending Notes memos via VB"
doc.sendTo = "
Call doc.Send(False, "")


Set doc = Nothing
Set db = Nothing
Set session = Nothing
End Sub


Sub mailsend2()
Dim Data As Variant
Dim mailcount As Integer
Dim s As Object, db As Object, doc As Object


Data = Range("A1:B6").Value 'defines the source data in two cols on
active sheet


Set s = CreateObject("Notes.NotesSession")
Set db = s.GETDATABASE("", "mail\username.nsf")
Set doc = db.CreateDocument()


For mailcount = 1 To 6


doc.Form = "Memo"
doc.sendTo = Data(mailcount, 1)
doc.Subject = Data(Str(mailcount), 2)
doc.Body = "Rats Trousers" & " " & Data(Str(mailcount), 2)
Call doc.Send(False)


Next


Set s = Nothing
Set db = Nothing
Set doc = Nothing


End Sub



--
Hmm...they have the Internet on COMPUTERS now!


"caddy" wrote:


lotus notes


--
caddy
------------------------------------------------------------------------
caddy's Profile: http://www.excelforum.com/member.php...o&userid=31858
View this thread: http://www.excelforum.com/showthread...hreadid=515843


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
Attaching an Excel File to an Email billbrandi Excel Discussion (Misc queries) 2 May 25th 09 01:22 PM
Attaching an Outlook email into a cell Joanne R Excel Discussion (Misc queries) 0 December 15th 08 11:17 PM
Attaching One Worksheet to Email KeshnerH Excel Programming 1 January 26th 05 07:27 PM
attaching tabs to email please help Excel Discussion (Misc queries) 3 January 19th 05 07:50 PM
Sending email WITHOUT attaching a workbook? Kobayashi[_5_] Excel Programming 2 September 25th 03 02:20 PM


All times are GMT +1. The time now is 12:41 PM.

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"