Discussion Locked

Mail from Access with attachment

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am currently using Access database to design a daily MIS which is used for reporting.
I now want to automate the e-mail reporting with the help of Access. I want to include some standard lines in the mail which will get generated from access. I tried to use macro - send object option but it has limitation of 255 characters. Is there any way i can extend the character limitation. Also, i want to attach the file to the e-mail which will be sent out.

1 reply

by jackofalltech

Which is very similar to VB. If you're any good you should be able to translate.

Func MailIt()
Local $oNewMail

$g_oOutlook = ObjGet("", "Outlook.Application")
If @Error then
MsgBox(16, $VERSION, "Outlook does not appear to be running")
Exit
EndIf

WinActivate("- Outlook")

$oNewMail = $g_oOutlook.CreateItem($olMailItem)
If Not IsObj($oNewMail) then
MsgBox(16, $VERSION, "Error creating new mail item")
Exit
EndIf

$oNewMail.Recipients.Add("_QRM")
If $oNewMail.Recipients.Count <> 1 then
MsgBox(16, $VERSION, "Error adding '_QRM' distribution list")
Exit
EndIf

If Not $oNewMail.Recipients.ResolveAll then
MsgBox(16, $VERSION, "Error adding '_QRM' distribution list")
Exit
EndIf

$oNewMail.Subject = "QRM: " & $g_sPDate
$oNewMail.Body = ""

$oNewMail.Attachments.Add(@ScriptDir & "\QRM_CriticalPath.xls")

; $oNewMail.Save
$oNewMail.Send
EndFunc

This discussion is closed to new replies.