Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help: XL & Outlook


Hi all,

I've created a Sub to send an email from excel as shown;


Code:
--------------------

Sub SendAnEmailWithOutlook(CurrFile)

Dim olApp As Outlook.Application
Dim olMail As MailItem

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

With olMail
.To = "
.CC = "
.Subject = "Textron Schedule Agreements: " & Right(CurrFile, 13)
.Attachments.Add CurrFile & ".xls"
.Display
.OriginatorDeliveryReportRequested = True
.ReadReceiptRequested = True
End With

Set olMail = Nothing
Set olApp = Nothing
End Sub

--------------------


I need to find out how I can determine whether or not the email had
actually been sent or not.

Any help appreciated! TIA


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=545045

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Help: XL & Outlook

Hi,

Sub SendAnEmailWithOutlook(CurrFile)

Dim olApp As Outlook.Application
Dim olMail As MailItem

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

With olMail
.To = "
.CC = "
.Subject = "Textron Schedule Agreements: " & Right(CurrFile, 13)
.Attachments.Add CurrFile & ".xls"
.Display
.OriginatorDeliveryReportRequested = True
.ReadReceiptRequested = True
..send 'added to send the mail
if .sent then
msgbox "Sent"
else
msgbox "Not sent"
end if
End With

Set olMail = Nothing
Set olApp = Nothing
End Sub

But I cannot see in the code you are sending it. (you need to add
".send").

Regards,
Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help: XL & Outlook


If I add .Send to the With statement then the email message will try and
send it automatically - I want the user to be able to add text the the
body of the email first before sending it.

Not sure what I can do from here?!

Ivan Raiminius Wrote:
Hi,

Sub SendAnEmailWithOutlook(CurrFile)

Dim olApp As Outlook.Application
Dim olMail As MailItem

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

With olMail
.To = "
.CC = "
.Subject = "Textron Schedule Agreements: " & Right(CurrFile, 13)
.Attachments.Add CurrFile & ".xls"
.Display
.OriginatorDeliveryReportRequested = True
.ReadReceiptRequested = True
..send 'added to send the mail
if .sent then
msgbox "Sent"
else
msgbox "Not sent"
end if
End With

Set olMail = Nothing
Set olApp = Nothing
End Sub

But I cannot see in the code you are sending it. (you need to add
".send").

Regards,
Ivan



--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=545045

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help: XL & Outlook


Hi,

I have a Function where it checks in the Sent Items Folder;


Code:
--------------------

Sub VerifyEmail(CurrFile, sentMail)

Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olMail As Outlook.MailItem
Dim lngRow As Long
Dim intAtt As Integer
Dim wbkTemp As Workbook
Dim strTempFile As String

Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olFolder = olNamespace.GetDefaultFolder(olFolderSentMail)

' go thru all mail in Sent Items
For Each olMail In olFolder.Items
' only check those with attachments
For intAtt = 1 To olMail.Attachments.count
' only those with xls files
If InStr(1, olMail.Attachments(intAtt).FileName, ".xls", vbTextCompare) 0 Then
' get folder and filename for xls file
strTempFile = ThisWorkbook.Path & Application.PathSeparator & olMail.Attachments(intAtt).FileName
' save it so we can open and read it
olMail.Attachments(intAtt).SaveAsFile strTempFile
Set wbkTemp = Workbooks.Open(strTempFile)
If Right(CurrFile, 13) & ".xls" = olMail.Attachments(intAtt).FileName Then
sentMail = True
End If
' close and destroy temporary excel file
wbkTemp.Close False
Set wbkTemp = Nothing
Kill strTempFile
End If
Next
Next
Set olMail = Nothing
Set olFolder = Nothing
Set olNamespace = Nothing
Set olApp = Nothing
End Sub

--------------------


This basically finds all the the attachment file names (in Sent Items
Folder), if an attachment name is the same as the currFile then the
file has been sent.......BUT I dont know how I can implement it into my
code so it runs when Oulook has closed?!

again, all ideas appreciated on this one! Cheers!


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=545045

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
Outlook 11 Outlook 10 Object Library Compatibility Issues Paul Mac[_4_] Excel Programming 11 May 19th 06 04:27 AM
Outlook Automation Error Problem - Can't locate Outlook Module Allan P. London[_2_] Excel Programming 1 August 14th 05 10:52 PM
How can I use Outlook express to send mail rather than Outlook by VBA code new.microsoft.com Excel Programming 1 August 1st 05 12:45 PM
Late Binding to Outlook from Excel: Outlook modifies email body Lenny Wintfeld Excel Programming 0 December 12th 04 04:03 PM
Display mail application either in Outlook, or Outlook express [email protected] Excel Programming 0 April 13th 04 09:50 PM


All times are GMT +1. The time now is 04:28 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"