send via gmail \9 not via outlook) (1 Viewer)

nobby

Nobby
Local time
Today, 21:42
Joined
Dec 28, 2008
Messages
24
Hi All
Checking the forums it looks like this is a heavily discussed topic
I need to send a report as an attachment via GMAIL. the code I have works well via OUTLOOK but i am now getting uneasy downgrading the security to allow outlook to work. I attach the code I have and wonder if someone far beter than I can tweak it to work

many Thanks

Private Sub emailInvoice_Click()
Dim strAttach1 As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim email As String
Me.Refresh
If Me.email = "" Then MsgBox ("There is no email address for this client" & Chr(13) & Chr(10) & "Either enter one (go to edit payers details )or print and post?"): End
Set objOutlook = CreateObject("Outlook.application")
Shell "Outlook.exe"
Set objEmail = objOutlook.CreateItem(olMailItem)
[FrmInvoiceJobsSub].SetFocus 'subform control
[FrmInvoiceJobsSub].Form![JobDescription].SetFocus 'Memo control on subform
'DoCmd.RunCommand acCmdSpelling
Me.Refresh

'Output Reports
Rem <!-- change "Reportx" to match the report names you wish to export. & _
IMPORTANT: Make sure the location you select to save your reports to exists, Access will & _
not create the folders for you. -->

DoCmd.OpenReport "rptInvoice", acViewPreview, , "InvoiceID = " & InvoiceID, , acHidden
DoCmd.OutputTo acOutputReport, "rptInvoice", acFormatPDF, "C:\tempinvoices\\Invoice.pdf", False
DoCmd.Close acReport, "rptinvoice"
'Set Attachments
Rem <!-- make sure to correlate the attachments to each of the reports you wish to send -->
strAttach1 = "C:\tempinvoices\\Invoice.pdf"
'Generate email
With objEmail
.Recipients.Add Forms!frminvoice!
.Subject = "Invoice Number " & [Invoice number]
.Body = "Please find attached our invoice number " & [Invoice number] & " dated " & [Invoice date] & Chr(13) & Chr(10) & "I hope you are in agreement with this and look forward to your payment on our agreed terms" & Chr(13) & Chr(10) & "We are as always at your service" _
& Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Zena Johnston" & Chr(13) & Chr(10) & "Finance"
.Display
.Attachments.Add strAttach1
End With
'Remove attachments from drive
Kill strAttach1
End Sub

Private Sub Form_Load()
Me.Refresh
End Sub
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 21:42
Joined
Jul 9, 2003
Messages
13,040
You forgot to format your code with code tags...
 

Users who are viewing this thread

Top Bottom