Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending from a standard mail account with outlook.... 1

Status
Not open for further replies.

checkOut

Technical User
Oct 17, 2002
153
NL
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
 
Hmm. Since I wrote the function shown above, I am probably well-placed to answer this question. The
Code:
FromAddr
is designed for users who have more than one Outlook mailbox set up. In my case, I have my personal mail account and also have access to a group mail account. If I want to send a mail from the group mail account, I can specify it in the
Code:
FromAddr
parameter, otherwise I leave this blank to send the mail from my personal account.

If you want to set up another mailbox, check under Tools, Services in Outlook. Then select your Exchange Server and click Properties. Select the Advanced tab and then Add another mailbox. Note: you have to have been given permissions to access the other mailbox for this to work! Therefore, I don't think that just specifying any old e-mail address in the
Code:
FromAddr
is going to work.

HTH [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top