[97] Sendobject Background in email

bodylojohn

Registered User.
Local time
Today, 13:56
Joined
Dec 28, 2005
Messages
205
Hello,

I want to send an order via email using the following code:

Code:
DoCmd.SendObject acSendNoObject, , , "info@sosol.nl", , , "Onderwerp", strMessage, False

This works fine.

But I want an image as background for the mail.
What do i have to put in the templatefile?
Just the path to the .jpg file?
 
Hi,

you could go for the code option as you can add a signature with it. you could save a html signature with your background and send that way.

i found this on the net ;)

Code:
   [COLOR=navy][FONT=&quot]Function GetBoiler(ByVal sFile As String) As String[/FONT][/COLOR]
    [COLOR=navy][FONT=&quot]    Dim fso As Object[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    Dim ts As Object[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    Set fso = CreateObject("Scripting.FileSystemObject")[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    GetBoiler = ts.readall[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    ts.Close[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]End Function[/FONT][/COLOR]
copy this into a module

Code:
 [COLOR=navy]Sub Mail_Outlook_With_Signature_Html()
[/COLOR][COLOR=black]' Don't forget to copy the function GetBoiler in the module.[/COLOR][COLOR=black]
' Working in Office 2000-2007[/COLOR][COLOR=navy]    
Dim OutApp As Object[/COLOR][COLOR=navy]    
Dim OutMail As Object[/COLOR][COLOR=navy]    
Dim strbody As String[/COLOR][COLOR=navy]    
Dim SigString As String[/COLOR][COLOR=navy]    
Dim Signature As String[/COLOR][COLOR=navy]    

Set OutApp = CreateObject("Outlook.Application")[/COLOR][COLOR=navy]    
OutApp.Session.Logon[/COLOR][COLOR=navy]    
Set OutMail = OutApp.CreateItem(0)[/COLOR][COLOR=navy]    
strbody = "<H3><B>Dear Customer</B></H3>" & _[/COLOR][COLOR=navy]             
"Please visit this website to download the new version.<br>" & _[/COLOR][COLOR=navy]             
 "Let me know if you have problems.<br>" & _[/COLOR][COLOR=navy]              
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _[/COLOR][COLOR=navy]              
"<br><br><B>Thank you</B>"

[/COLOR][COLOR=black]'Use the second SigString if you use Vista as operating system[/COLOR][COLOR=navy]    
SigString = "C:\Documents and Settings\" & Environ("username") & _[/COLOR][COLOR=navy]                
"\Application Data\Microsoft\Signatures\Mysig.htm"[/COLOR][COLOR=black]    
'SigString = "C:\Users\" & Environ("username") & _[/COLOR][COLOR=black]     
"\AppData\Roaming\Microsoft\Signatures\Mysig.htm"[/COLOR][COLOR=navy]   
If Dir(SigString) <> "" Then[/COLOR][COLOR=navy]       
Signature = GetBoiler(SigString)[/COLOR][COLOR=navy]    
Else[/COLOR][COLOR=navy]        
Signature = ""[/COLOR][COLOR=navy]    
End If[/COLOR][COLOR=navy]    

On Error Resume Next[/COLOR][COLOR=navy]    

With OutMail[/COLOR][COLOR=navy]        
.To = "ron@debruin.nl"[/COLOR][COLOR=navy]        
.CC = ""[/COLOR][COLOR=navy]        
.BCC = ""[/COLOR][COLOR=navy]        
.Subject = "This is the Subject line"[/COLOR][COLOR=navy]        
.HTMLBody = strbody & "<br><br>" & Signature[/COLOR][COLOR=black]       

 'You can add files also like this[/COLOR][COLOR=black]        
'.Attachments.Add ("C:\test.txt")[/COLOR][COLOR=navy]        
.Send   [/COLOR][COLOR=black]'or use .Display[/COLOR][COLOR=navy]   
End With[/COLOR][COLOR=navy]    

On Error GoTo 0[/COLOR][COLOR=navy]    

Set OutMail = Nothing[/COLOR][COLOR=navy]    
Set OutApp = Nothing[/COLOR][COLOR=navy]End Sub[/COLOR]

regs,


Nigel
 
Hi,

you could go for the code option as you can add a signature with it. you could save a html signature with your background and send that way.

i found this on the net ;)

Code:
   [COLOR=navy][FONT=&quot]Function GetBoiler(ByVal sFile As String) As String[/FONT][/COLOR]
    [COLOR=navy][FONT=&quot]    Dim fso As Object[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    Dim ts As Object[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    Set fso = CreateObject("Scripting.FileSystemObject")[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    GetBoiler = ts.readall[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]    ts.Close[/FONT][/COLOR]
  [COLOR=navy][FONT=&quot]End Function[/FONT][/COLOR]
copy this into a module

Code:
 [COLOR=navy]Sub Mail_Outlook_With_Signature_Html()
[/COLOR][COLOR=black]' Don't forget to copy the function GetBoiler in the module.[/COLOR][COLOR=black]
' Working in Office 2000-2007[/COLOR][COLOR=navy]    
Dim OutApp As Object[/COLOR][COLOR=navy]    
Dim OutMail As Object[/COLOR][COLOR=navy]    
Dim strbody As String[/COLOR][COLOR=navy]    
Dim SigString As String[/COLOR][COLOR=navy]    
Dim Signature As String[/COLOR][COLOR=navy]    

Set OutApp = CreateObject("Outlook.Application")[/COLOR][COLOR=navy]    
OutApp.Session.Logon[/COLOR][COLOR=navy]    
Set OutMail = OutApp.CreateItem(0)[/COLOR][COLOR=navy]    
strbody = "<H3><B>Dear Customer</B></H3>" & _[/COLOR][COLOR=navy]             
"Please visit this website to download the new version.<br>" & _[/COLOR][COLOR=navy]             
 "Let me know if you have problems.<br>" & _[/COLOR][COLOR=navy]              
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _[/COLOR][COLOR=navy]              
"<br><br><B>Thank you</B>"

[/COLOR][COLOR=black]'Use the second SigString if you use Vista as operating system[/COLOR][COLOR=navy]    
SigString = "C:\Documents and Settings\" & Environ("username") & _[/COLOR][COLOR=navy]                
"\Application Data\Microsoft\Signatures\Mysig.htm"[/COLOR][COLOR=black]    
'SigString = "C:\Users\" & Environ("username") & _[/COLOR][COLOR=black]     
"\AppData\Roaming\Microsoft\Signatures\Mysig.htm"[/COLOR][COLOR=navy]   
If Dir(SigString) <> "" Then[/COLOR][COLOR=navy]       
Signature = GetBoiler(SigString)[/COLOR][COLOR=navy]    
Else[/COLOR][COLOR=navy]        
Signature = ""[/COLOR][COLOR=navy]    
End If[/COLOR][COLOR=navy]    

On Error Resume Next[/COLOR][COLOR=navy]    

With OutMail[/COLOR][COLOR=navy]        
.To = "ron@debruin.nl"[/COLOR][COLOR=navy]        
.CC = ""[/COLOR][COLOR=navy]        
.BCC = ""[/COLOR][COLOR=navy]        
.Subject = "This is the Subject line"[/COLOR][COLOR=navy]        
.HTMLBody = strbody & "<br><br>" & Signature[/COLOR][COLOR=black]       

 'You can add files also like this[/COLOR][COLOR=black]        
'.Attachments.Add ("C:\test.txt")[/COLOR][COLOR=navy]        
.Send   [/COLOR][COLOR=black]'or use .Display[/COLOR][COLOR=navy]   
End With[/COLOR][COLOR=navy]    

On Error GoTo 0[/COLOR][COLOR=navy]    

Set OutMail = Nothing[/COLOR][COLOR=navy]    
Set OutApp = Nothing[/COLOR][COLOR=navy]End Sub[/COLOR]

regs,


Nigel

Thank you for the effort...

But I am using outlook express 6

Could this code be adjusted for outlook express?
 
Hi john,

as far as i am aware, Outlook express will work. you just need to reference it in the vba editor. Tools/References.

alternatively,

you can use the smtp approach posted recently. do a search for it :)


Nigel
 
Hi,

here is the smtp version-

Code:
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
with objMessage
	.Subject = "Example CDO Message"
	.From = """Me"" <me@my.com>"
	.To = "test@paulsadowski.com"
	.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."
end with

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

i would guess you could combine both so that the smtp version can send html or something like that.

i will have a play around later



Nigel
 

Users who are viewing this thread

Back
Top Bottom