Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Excel macro to create Outlook e-mail

I realize that this is a repeat of a question from yesterday - but no one
answered it.

The macro below will safe a draft when outlook is open, but will not when
outlook is closed. How can I make the change to save a draft - even if
outlook is closed?

This is my poor attempt in creating a Macro - if you see improvements that I
can make please let me know.....


Option Explicit

Sub SendFileToEmail()
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim strTo As String, strCC As String, strBody As String
Dim iRow As Long, inrec As String
Set objOutlook = CreateObject("Outlook.Application")
' Set objOutlookMsg = objOutlook.CreateItem(0)
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Dim File1, File2 As String
Dim myCell

iRow = 0
strTo = ""
With shtEmail.Range("EmailToList")
Do
strTo = strTo & .Offset(iRow, 0).Value & ";"
iRow = iRow + 1
Loop Until .Offset(iRow, 0) = ""
End With

' iRow = 0
' strCC = ""
' With shtEmail.Range("CCToList")
' Do
' strCC = strCC & .Offset(iRow, 0).Value & ";"
' iRow = iRow + 1
' Loop Until .Offset(iRow, 0) = ""
' End With

For Each myCell In shtInput.Range("LifeSummary")
strBody = strBody & myCell.Value & vbCrLf
Next


With objOutlookMsg
'.SentonBehalfofName = "
..To = strTo
' .Cc = strCC
'.bcc = "
..Subject = "Today's information"
'.BodyFormat = olFormatPlain
..BodyFormat = olFormatHTML
..HTMLBody = "<html<pre" & strBody & "</pre</html"
'.Attachments.Add ("myfilenamewithfullpath.xls")
' .Send 'Let´s go!
..Save ' stick it in drafts
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
jaf jaf is offline
external usenet poster
 
Posts: 300
Default Excel macro to create Outlook e-mail

Brad,
See GetObject in Help.
You can use it to test if Outlook is open, if not open it.

There may be a way to save a draft to a closed Outlook using MAPI.
It's really an Outlook problem. You should try the Outlook groups.

John


"Brad" wrote in message
...
I realize that this is a repeat of a question from yesterday - but no one
answered it.

The macro below will safe a draft when outlook is open, but will not when
outlook is closed. How can I make the change to save a draft - even if
outlook is closed?

This is my poor attempt in creating a Macro - if you see improvements that
I
can make please let me know.....


Option Explicit

Sub SendFileToEmail()
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim strTo As String, strCC As String, strBody As String
Dim iRow As Long, inrec As String
Set objOutlook = CreateObject("Outlook.Application")
' Set objOutlookMsg = objOutlook.CreateItem(0)
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Dim File1, File2 As String
Dim myCell

iRow = 0
strTo = ""
With shtEmail.Range("EmailToList")
Do
strTo = strTo & .Offset(iRow, 0).Value & ";"
iRow = iRow + 1
Loop Until .Offset(iRow, 0) = ""
End With

' iRow = 0
' strCC = ""
' With shtEmail.Range("CCToList")
' Do
' strCC = strCC & .Offset(iRow, 0).Value & ";"
' iRow = iRow + 1
' Loop Until .Offset(iRow, 0) = ""
' End With

For Each myCell In shtInput.Range("LifeSummary")
strBody = strBody & myCell.Value & vbCrLf
Next


With objOutlookMsg
'.SentonBehalfofName = "
.To = strTo
' .Cc = strCC
'.bcc = "
.Subject = "Today's information"
'.BodyFormat = olFormatPlain
.BodyFormat = olFormatHTML
.HTMLBody = "<html<pre" & strBody & "</pre</html"
'.Attachments.Add ("myfilenamewithfullpath.xls")
' .Send 'Let´s go!
.Save ' stick it in drafts
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Excel macro to create Outlook e-mail

Thank you!
--
Wag more, bark less


"jaf" wrote:

Brad,
See GetObject in Help.
You can use it to test if Outlook is open, if not open it.

There may be a way to save a draft to a closed Outlook using MAPI.
It's really an Outlook problem. You should try the Outlook groups.

John


"Brad" wrote in message
...
I realize that this is a repeat of a question from yesterday - but no one
answered it.

The macro below will safe a draft when outlook is open, but will not when
outlook is closed. How can I make the change to save a draft - even if
outlook is closed?

This is my poor attempt in creating a Macro - if you see improvements that
I
can make please let me know.....


Option Explicit

Sub SendFileToEmail()
Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim strTo As String, strCC As String, strBody As String
Dim iRow As Long, inrec As String
Set objOutlook = CreateObject("Outlook.Application")
' Set objOutlookMsg = objOutlook.CreateItem(0)
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Dim File1, File2 As String
Dim myCell

iRow = 0
strTo = ""
With shtEmail.Range("EmailToList")
Do
strTo = strTo & .Offset(iRow, 0).Value & ";"
iRow = iRow + 1
Loop Until .Offset(iRow, 0) = ""
End With

' iRow = 0
' strCC = ""
' With shtEmail.Range("CCToList")
' Do
' strCC = strCC & .Offset(iRow, 0).Value & ";"
' iRow = iRow + 1
' Loop Until .Offset(iRow, 0) = ""
' End With

For Each myCell In shtInput.Range("LifeSummary")
strBody = strBody & myCell.Value & vbCrLf
Next


With objOutlookMsg
'.SentonBehalfofName = "
.To = strTo
' .Cc = strCC
'.bcc = "
.Subject = "Today's information"
'.BodyFormat = olFormatPlain
.BodyFormat = olFormatHTML
.HTMLBody = "<html<pre" & strBody & "</pre</html"
'.Attachments.Add ("myfilenamewithfullpath.xls")
' .Send 'Let´s go!
.Save ' stick it in drafts
End With
Set objOutlookMsg = Nothing
Set objOutlook = 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
E-Mail attachment to same e-mail address in Outlook Vick Excel Discussion (Misc queries) 4 May 17th 07 07:53 PM
Macro to send a mail to outlook [email protected] Excel Discussion (Misc queries) 1 August 24th 06 12:48 PM
e-mail from excel when outlook is not in use Jignesh Khandwala Excel Discussion (Misc queries) 5 April 7th 06 09:52 AM
is it possible to link a cell in excel to a mail in outlook? bembel Excel Discussion (Misc queries) 4 October 24th 05 03:44 PM
Excel/Outlook Mail Merge??? WhoaNelly Excel Discussion (Misc queries) 3 April 26th 05 04:24 PM


All times are GMT +1. The time now is 09:53 PM.

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"