hello all.
I have a report that needs to be sent to different users using BCA. I want to send those reports via e-mail ID. I did a search on this board. All of the VBA code I found, got the solution by creating a MAPI Session -using Lotus notes/Outlook.
But I am looking for a solution in which i dont need to use notes/outlook . Is there any solution just by using e-mail id? Just need to send this report to BCA and distribute to user mail Ids. Thanks in advance for your help.
I’m sure BCA Publisher could do this, but it’s unlikely a good alternative for you. The solutions provided use MAPI, because the vast majority of customers can do it this way. There is likely nothing preventing you from using a generic SMTP gateway and supplying the appropriate parameters. In fact, this is what BCA Publisher does.l
I don’t have a sample, but this may give you soe ideas.
I can confirm that Steve’s suggestion does work. Using CDO (Collaboration Data Objects) and a SMTP server is a barebones, but “easy” solution. The benefit is that CDO is already “there” in any Windows installation … MAPI / Outlook / Lotus Notes, may not.
hello everybody, Thanks for ur suggestions.
Actually, I have no problem using VB code. but if that code includes a MAPI session…etc, then it is giving me headache. you were right, I have CDO, So using SMTP sever can i generate something? Thanks in Advance.
Dim Cfg As CDO.Configuration
Dim Msg As CDO.Message
'establish server settings
Set Cfg = New CDO.Configuration
Cfg.Fields(cdoSendUsingMethod) = cdoSendUsingPort
Cfg.Fields(cdoSMTPServer) = "smtp.server.address"
Cfg.Fields.Update
'now create and send the message
Set Msg = New CDO.Message
Set Msg.Configuration = Cfg 'use the server settings established above
Msg.From = "user@address.com"
Msg.To = "user@address.com
Msg.CC = "user@address.com"
Msg.Subject = "text"
Msg.TextBody = "text"
Msg.AddAttachment "filename"
Msg.Send
No problem. Also, a search for CDO here on BOB may also give you some other ideas. If I remember correctly, there are also links to other online resources regarding CDO.
hi Dwayne, this might be a stupid Q, but I need to know…
I am trying to implement your code, I dont have SMTP server Address. How can i get the Server address?
Our Admin is on vacation and nobody is around to ask,…people around dont know!
there should be a way, Thanks in advance for help!
hey Dwayne,
I was able to find the port num for SMTP : 25
name: Default SMTP Virtual Server
But its IP address says: (All Unassigned)(But if i pull down the box there is another IP address…should i use this address?) let me know…
Thanks
Sorry, I don’t know the address of your smtp server either . I’m not familiar enough with the network / server side of things to know if it’s possible to reverse engineer it either. Good luck.
hi Dwayne,
I tried to implement ur code. I encounterd the following error!
“run-time error ‘-2147220977(8004020f):’
the server rejected one or more recipient addresses. the server responce was 550 5.7.1 Unable to relay for Username@email.com”
I tried by changing the username too, still i get the error!
This is a Server configuration issue. It seems that the SMTP server is configured NOT to forward messages (i.e. Not to act as an Open relay).
You might want to:
Talk to your Network admin about it
You may need to authenticate with a valid username/pwd before sending emails
3.If this SMTP server is handling emails for the domain you are sending emails to (e.g. yourcompany.com ) then try sending an email from you@yourcompany.com to you@yourcompany.com.
Have a look at the Outlook Express / Outlook settings to know what configuration is expected by server.
Hi,
l am using this code, but can’t seem to make it work. lt is refreshing data, but l don’t get email notification. thanks
Public Sub SendEmail()
Dim ObjMessage As CDO.Message
Dim Cfg As CDO.Configuration
Dim Msg As CDO.Message
Dim doc As Document
Dim docname, tempdoc As String
Dim Rep As REPORT
Dim i As Integer
Set doc = ActiveDocument
doc.Refresh
doc.Save
docname = doc.FullName
tempdoc = doc.Name & format(Now, "MM-DD-YYYY hh\hmm")
doc.SaveAs (tempdoc)
For i = 1 To doc.Reports.Count
Set Rep = doc.Reports.Item(i)
Rep.ExportAsPDF ("C:\Reports\" & Rep.Name)
Next i
On Error Resume Next
Set ObjMessage = New CDO.Message
'establish server settings
Set Cfg = New CDO.Configuration
Cfg.Fields(cdoSendUsingMethod) = 25
Cfg.Fields(cdoSMTPServer) = "mailhost.global.com"
Cfg.Fields.Update
'now create and send the message
Set Msg = New CDO.Message
Set Msg.Configuration = Cfg 'use the server settings established above
Msg.From = "joy@jjj.com"
Msg.To = "joy@jjj.com "
'Msg.CC = "user@address.com"
Msg.subject = "bca text"
Msg.TextBody = "testing"
Msg.AddAttachment "doc"
Msg.Send
End Sub
I’m not sure if this is causing it, but the .AddAttachment line doesn’t look right. The parameter is the filename to be attached, so unless you have a file literally named “doc” (current path, no extension) that portion is failing. What you probably want is Msg.AddAttachment Doc.Fullname, and I’m not sure if the file will attach while it is still open. You’d have to test that part.
Again, I’m not sure if that is causing the email message to fail, but I’m pretty sure it’s a problem of some sort.