I have the function below, get it from this site...
I have an automated email function which send mails by criteria. It's loaded from the main form in my application.
The problem is: The email everytime come from a different user, so not everybody is understanding what happens.
With this function it's possible to send mail from an other adress. I think it's necc. the adress is from the sender but maybe the following is possible: give: actions@companyname.com as sender by the mail.
If this is possible, how? Is it necc. to make a standard mail adres for every user?
Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional BCC, _
Optional Subject, Optional MessageText, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)
' Code sample from Accessory
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim TestEmail As Variant, I As Integer
Set objOutlook = CreateObject("Outlook.Application"
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If
If Not IsMissing(Addr) Then
TestEmail = split(Addr, ";"
For I = 0 To UBound(TestEmail)
Set objOutlookRecip = .Recipients.Add(TestEmail(I))
Next I
objOutlookRecip.type = olTo
End If
If Not IsMissing(CC) Then
TestEmail = split(CC, ";"
For I = 0 To UBound(TestEmail)
Set objOutlookRecip = .Recipients.Add(TestEmail(I))
Next I
objOutlookRecip.type = olCC
End If
If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.type = olBCC
End If
If Not IsMissing(Subject) Then
.Subject = Subject
End If
If Not IsMissing(MessageText) Then
.Body = MessageText
End If
If IsNull(Vote) = False Then
.VotingOptions = Vote
End If
Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
If EditMessage Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
Gerard
I have an automated email function which send mails by criteria. It's loaded from the main form in my application.
The problem is: The email everytime come from a different user, so not everybody is understanding what happens.
With this function it's possible to send mail from an other adress. I think it's necc. the adress is from the sender but maybe the following is possible: give: actions@companyname.com as sender by the mail.
If this is possible, how? Is it necc. to make a standard mail adres for every user?
Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional BCC, _
Optional Subject, Optional MessageText, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)
' Code sample from Accessory
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim TestEmail As Variant, I As Integer
Set objOutlook = CreateObject("Outlook.Application"
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If
If Not IsMissing(Addr) Then
TestEmail = split(Addr, ";"
For I = 0 To UBound(TestEmail)
Set objOutlookRecip = .Recipients.Add(TestEmail(I))
Next I
objOutlookRecip.type = olTo
End If
If Not IsMissing(CC) Then
TestEmail = split(CC, ";"
For I = 0 To UBound(TestEmail)
Set objOutlookRecip = .Recipients.Add(TestEmail(I))
Next I
objOutlookRecip.type = olCC
End If
If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.type = olBCC
End If
If Not IsMissing(Subject) Then
.Subject = Subject
End If
If Not IsMissing(MessageText) Then
.Body = MessageText
End If
If IsNull(Vote) = False Then
.VotingOptions = Vote
End If
Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
If EditMessage Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
Gerard