C
Cindy
Can you help?
via a command button, I need to be able to email the
workbook on the screen as an attachment. I'd like to open
Outlook with code and add the attachment. I don't want to
send or address the email - the user needs to do this.
I tried the following code but it seems to force me to
include the email address and automatically send it.
Don't know what I'm doing wrong. Thank you
Dim OLF As Outlook.MAPIFolder, olMailItem As
Outlook.MailItem
Dim ToContact As Outlook.Recipient
Set OLF = GetObject("", _
"Outlook.Application").GetNamespace
("MAPI").GetDefaultFolder(olFolderInbox)
Set olMailItem = OLF.Items.Add ' creates a new e-mail
message
With olMailItem
.Subject = "PDA Request" ' message subject
Set ToContact = .Recipients.Add("email
address.com") ' add a recipient
.Body = "test PDA request" & Chr(13)
' the message text with a line break
.Attachments.Add "P:\PDA\PDA Request shell.xlt",
olByValue, , _
"Attachment" ' insert attachment
' .Attachments.Add "C:\FolderName\Filename.txt",
olByReference, , _
"Shortcut to Attachment" ' insert shortcut
' .Attachments.Add "C:\FolderName\Filename.txt",
olEmbeddedItem, , _
"Embedded Attachment" ' embedded attachment
' .Attachments.Add "C:\FolderName\Filename.txt",
olOLE, , _
"OLE Attachment" ' OLE attachment
' .OriginatorDeliveryReportRequested = True '
delivery confirmation
' .ReadReceiptRequested = True ' read confirmation
' .Application
.Save ' saves the message for later editing
.Send ' sends the e-mail message (puts it in the
Outbox)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
Set OLF = Nothing
via a command button, I need to be able to email the
workbook on the screen as an attachment. I'd like to open
Outlook with code and add the attachment. I don't want to
send or address the email - the user needs to do this.
I tried the following code but it seems to force me to
include the email address and automatically send it.
Don't know what I'm doing wrong. Thank you
Dim OLF As Outlook.MAPIFolder, olMailItem As
Outlook.MailItem
Dim ToContact As Outlook.Recipient
Set OLF = GetObject("", _
"Outlook.Application").GetNamespace
("MAPI").GetDefaultFolder(olFolderInbox)
Set olMailItem = OLF.Items.Add ' creates a new e-mail
message
With olMailItem
.Subject = "PDA Request" ' message subject
Set ToContact = .Recipients.Add("email
address.com") ' add a recipient
.Body = "test PDA request" & Chr(13)
' the message text with a line break
.Attachments.Add "P:\PDA\PDA Request shell.xlt",
olByValue, , _
"Attachment" ' insert attachment
' .Attachments.Add "C:\FolderName\Filename.txt",
olByReference, , _
"Shortcut to Attachment" ' insert shortcut
' .Attachments.Add "C:\FolderName\Filename.txt",
olEmbeddedItem, , _
"Embedded Attachment" ' embedded attachment
' .Attachments.Add "C:\FolderName\Filename.txt",
olOLE, , _
"OLE Attachment" ' OLE attachment
' .OriginatorDeliveryReportRequested = True '
delivery confirmation
' .ReadReceiptRequested = True ' read confirmation
' .Application
.Save ' saves the message for later editing
.Send ' sends the e-mail message (puts it in the
Outbox)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
Set OLF = Nothing