I have VBA code that sends an email with an attachment when executed. The attachment is an excel spreadsheet. When the email is received, however, a gray icon appears in the email instead of the excel icon. Whey I try to process this attachment through vba code, the attachment is not viewed as a RICHTEXT, but rather as TEXT, which is preventing me from detaching it via VBA. How do I get the icon to display as an Excel icon?
My code for attaching the email and sending it is shown below:
' Declare Variables for file and macro setup
Dim UserName, MailDbName, MailMessage As String
Dim Maildb, MailDoc, Session, EmbedObj1, AttachME As Object
Dim RichTextBody, RichTextAttachment As Object
' Open and locate current LOTUS NOTES User
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
Recipient = "email id"
MailDoc.SendTo = Recipient
MailDoc.Subject = "PILOT: Software Audit Results"
MailMessage = "Software audit results attached."
Set RichTextBody = MailDoc.CREATERICHTEXTITEM("Body")
MailDoc.Body = MailMessage
MailDoc.SAVEMESSAGEONSEND = True
If Attachment1 <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment1, "Attachment")
MailDoc.PostedDate = Now()
On Error GoTo ErrorHandler1
MailDoc.Send 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
Set AttachME = Nothing