View Single Post
  #5  
Old May 29th 09, 03:24 PM posted to microsoft.public.outlook.program_vba
Cyberwolf
external usenet poster
 
Posts: 5
Default Sending a email using an account setup for the process sending

Currently I am using htis code to send emails with pdf attachements

Const oMailItem As Long = 0

Public Function SendMail(DisplayMsg As Boolean, strTo As String, strSubject
As String, strBody As String, Optional strAttachPathFile As String, Optional
strCC As String, Optional strBCC As String)


Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object
'Dim objOutlook As Outlook.Application
'Dim objOutlookMsg As Outlook.MailItem
'Dim objOutlookRecip As Outlook.Recipient
'Dim objOutlookAttach As Outlook.Attachment
'Dim oOutlook As Object
'Dim omail As Object

'Set oOutlook = CreateObject("Outlook.Application")
'Set omail = oOutlook.CreateItem(olMailItem)

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(oMailItem)
With objOutlookMsg


'Add "To" recipient
'Set objOutlookRecip = .Recipients.Add(strTo)
'objOutlookRecip.Type = olTo
.To = strTo
'.SentOnBehalfOfName = "RAMP"
'"Add "CC" recipient
If strCC "" Then
.CC = strCC
End If

'Add "BCC" recipient
If strBCC "" Then
..BCC = strBCC
End If

'Add subject, body, and importance of the E-Mail Messzage
objOutlookMsg.Subject = strSubject
objOutlookMsg.Body = strBody
'objOutlookMsg.Importance =

'Add Attachment
If strAttachPathFile "" Then
objOutlookMsg.Attachments.Add strAttachPathFile, 1
' .Attachments.Add (strAttachPathFile)
End If

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next objOutlookRecip
objOutlookMsg.Send
End With

Set objOutlookMsg = Nothing
objOutlook.Quit
Set objOutlook = Nothing

End Function

I was hoping to modifiy this code to suit my needs
--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


"SvenC" wrote:

"Cyberwolf" wrote in message
...
currently we are having a problem where some of the useres are on the OWA
version, and I am getting Outlook installed on their pc's. But we would
also
like to see the email being sent from that account. That way we can track
any outgoing emails easily to see what time it was actually sent out
according to the sent folder.


Again: how do you currently send those mails. Maybe you can
change your current approach which could cause less trouble
than searching a completely new way.

Sending mails automatically with the Outlook Object Model
will typically cause security dialog pop ups which is obviously
not good for an automatic process.

--
SvenC


Ads