K
Keith
I'm using Office 2003 on WinXP.
I have several gif files that I create in Excel (from Excel ranges) and
within Excel, I want to create an email that attaches these GIF files and
sends them to the target recipient. I have this working (in theory) when
sending to myself, but there are a few things not working properly, and I'm
hoping someone here can help- even though the code below is run from Excel,
folks here are more likely to be able to spot syntax issues related to the
code that manipulates Outlook.
Goal: to have the images show up inline, e.g. visible when the email is
opened (currently it shows up as an attached file that then needs to be
opened). My default outlook email editor is Word2003, and I can do this by
creating a new email, and inserting an image:
Selection.InlineShapes.AddPicture FileName:="C:\AEPARDAV1.gif", LinkToFile _
:=False, SaveWithDocument:=True
However, I'm not sure that Word is part of the equation when I run my code
directly from Excel:
Function Mail_Selection_Range_Outlook_Body(SendToName As String,
SendFileCount As Integer)
' code adapted from http://www.rondebruin.nl/mail/
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
FName = "c:\" & SendToName
FExt = ".gif"
On Error Resume Next
With OutMail
.To = "rucksk" 'SendToName
.CC = ""
.BCC = ""
.Subject = "Roadblocks data update request"
.Body.Add = "Please respond to this email, and include comments and
updates directly under each row"
'.Body.Add = Chr(13)
For n = 1 To SendFileCount
.Attachments.Add (FName & CStr(n) & FExt) ' this is where it adds as
an attachment instead of inline
'.Body.Add = Chr(13)
Next
.Send 'or use .Display
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Function
I have several gif files that I create in Excel (from Excel ranges) and
within Excel, I want to create an email that attaches these GIF files and
sends them to the target recipient. I have this working (in theory) when
sending to myself, but there are a few things not working properly, and I'm
hoping someone here can help- even though the code below is run from Excel,
folks here are more likely to be able to spot syntax issues related to the
code that manipulates Outlook.
Goal: to have the images show up inline, e.g. visible when the email is
opened (currently it shows up as an attached file that then needs to be
opened). My default outlook email editor is Word2003, and I can do this by
creating a new email, and inserting an image:
Selection.InlineShapes.AddPicture FileName:="C:\AEPARDAV1.gif", LinkToFile _
:=False, SaveWithDocument:=True
However, I'm not sure that Word is part of the equation when I run my code
directly from Excel:
Function Mail_Selection_Range_Outlook_Body(SendToName As String,
SendFileCount As Integer)
' code adapted from http://www.rondebruin.nl/mail/
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
FName = "c:\" & SendToName
FExt = ".gif"
On Error Resume Next
With OutMail
.To = "rucksk" 'SendToName
.CC = ""
.BCC = ""
.Subject = "Roadblocks data update request"
.Body.Add = "Please respond to this email, and include comments and
updates directly under each row"
'.Body.Add = Chr(13)
For n = 1 To SendFileCount
.Attachments.Add (FName & CStr(n) & FExt) ' this is where it adds as
an attachment instead of inline
'.Body.Add = Chr(13)
Next
.Send 'or use .Display
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Function